How to upload a file on Google Cloud, in a specific bucket directory (e.g. foo
)?
\"use strict\";
const gcloud = require(\"gcloud\");
const PROJECT
If you want to use async-await while uploading files into storage buckets the callbacks won't do the job, Here's how I did it.
async function uploadFile() {
const destPath = 'PATH_TO_STORAGE/filename.extension';
await storage.bucket("PATH_TO_YOUR_BUCKET").upload(newFilePath, {
gzip: true,
destination: destPath,
});
}
Hope it helps someone!