/** * 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);
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
[[["Facile à comprendre","easyToUnderstand","thumb-up"],["J'ai pu résoudre mon problème","solvedMyProblem","thumb-up"],["Autre","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"],["Problème de traduction","translationIssue","thumb-down"],["Autre","otherDown","thumb-down"]],[],[],[]]