javascript - 从 Google Cloud Functions (JS) 中运行 Google Storage Command
问题描述
我正在使用 Cloud Functions 将 GCS 中文件夹的全部内容移动到同一存储桶中的另一个文件夹。我正在使用 Javascript。尽管存储桶和源对象存在,但我不断收到该对象不存在的错误。
这是云函数代码:
// Imports the Google Cloud client library
const {Storage} = require('@google-cloud/storage');
// Creates a client
const storage = new Storage();
async function moveFile() {
// Moves the file within the bucket
await storage
.bucket("my-bucket")
.file("folder/source/**")
.move("folder/target/**");
console.log(
`gs://${bucketName}/${srcFilename} moved to gs://${bucketName}/${destFilename}.`
);
}
exports.moveContent = (req, res) => {
moveFile().catch(console.error);
res.send("done")
}
这是 package.json 的来源
{
"name": "move-content",
"version": "0.0.1",
"dependencies": {
"googleapis": "37.1.0",
"@google-cloud/storage": "^4.5.0"
}
}
这是我得到的错误(来自谷歌日志):
move-content 3m89p16m58bb { Error: file#copy failed with an error - No such object: my-bucket/folder/source/** at new ApiError (/srv/node_modules/@google-cloud/common/build/src/util.js:58:15) at Util.parseHttpRespBody (/srv/node_modules/@google-cloud/common/build/src/util.js:193:38) at Util.handleResp
...
我错过了什么……?
谢谢
解决方案
推荐阅读
- android - 不同机器上相同设备的不同 Settings.Secure.ANDROID_ID
- video-capture - 有没有办法用赛普拉斯手动录制视频?
- php - rabbitmq - 即使上面有消息,队列似乎也是空的
- asp.net-web-api - IE 11 问题::SCRIPT7002:XMLHttpRequest:网络错误 0x2eff
- java - Java jdbc Sql Server 并行写入
- r - 从 cva.glmnet 对象中提取最佳参数
- reactjs - 在 console.log 中调用未定义的 api
- r - 某些图(堆积条形图)未显示 x 轴标签
- ubuntu - Puppet 5 文件服务器在 Ubuntu 18 中不工作
- elasticsearch - 弹性搜索查询所有字段,包括嵌套字段