/** * TODO(developer): Uncomment the following lines before running the sample. */// The ID of your GCS bucket// const bucketName = 'your-unique-bucket-name';// The contents that you want to upload// const contents = 'these are my contents';// The new ID for your GCS file// const destFileName = 'your-new-file-name';// Imports the Google Cloud Node.js client libraryconst{Storage}=require('@google-cloud/storage');// Creates a clientconststorage=newStorage();asyncfunctionuploadWithoutAuthenticationCreateResumableUploadStrategy(){constfile=storage.bucket(bucketName).file(destFileName);// Returns an authenticated endpoint to which// you can make requests without credentials.const[location]=awaitfile.createResumableUpload();//auth required// Passes the location to file.save so you don't need to// authenticate this callawaitfile.save(contents,{uri:location,resumable:true,validation:false,});console.log(`${destFileName} uploaded to ${bucketName}`);}uploadWithoutAuthenticationCreateResumableUploadStrategy().catch(console.error);
Nächste Schritte
Informationen zum Suchen und Filtern von Codebeispielen für andere Google Cloud-Produkte finden Sie im Google Cloud-Beispielbrowser.
[[["Leicht verständlich","easyToUnderstand","thumb-up"],["Mein Problem wurde gelöst","solvedMyProblem","thumb-up"],["Sonstiges","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Problem mit der Übersetzung","translationIssue","thumb-down"],["Sonstiges","otherDown","thumb-down"]],[],[],[]]