【发布时间】:2017-04-12 10:44:45
【问题描述】:
我有一个 Node.js 服务器,我正在使用 google-cloud 包将一些图像文件上传到 Firebase 存储。
上传本身工作正常,但 google-cloud API 似乎只能将文件上传到 Firebase Storage 根文件夹。
有没有办法指定上传图片的远程位置?
我现在在做什么:
const serviceAccount = require('./serviceAccount.json');
const storage = gcloud.storage({
projectId: '*projectId*',
credentials: serviceAccount
});
const storageBucket = storage.bucket('*bucket*');
storageBucket.upload(localFsPath)
.then(data => /* Some stuff */)
.catch(err => console.log(err));
有没有办法做这样的事情?
storageBucket.upload(path, { destination: 'a/b/c/file.jpg' })
.then(data => /* Some stuff */)
.catch(err => console.log(err));
【问题讨论】:
-
你试过
{destination: newPath}吗?因为这正是它的工作原理。见doc -
@Jérôme 仅供参考,文档链接是 404。
标签: javascript node.js google-cloud-storage google-cloud-platform