我正在使用以下代码从我的云函数的一个存储中复制文件:
exports.copyFile = functions.storage.object().onFinalize((object) => {
const Storage = require('@google-cloud/storage');
const storage = new Storage();
const srcBucketName = 'bucket1';
const srcFilename = object.name;
const destBucketName = 'bucket2';
const destFilename = 'example.png';
storage
.bucket(srcBucketName)
.file(srcFilename)
.copy(storage.bucket(destBucketName).file(destFilename))
.then(() => {
console.log(
`gs://${srcBucketName}/${srcFilename} copied to gs://${destBucketName}/${destFilename}.`
);
return console.log('done!');
})
.catch(err => {
console.error('ERROR:', err);
})
});我在日志中收到以下错误:
ERROR: { ApiError: Not Found
at Object.parseHttpRespBody....}不知道少了什么。有什么帮助吗?
发布于 2018-07-25 21:01:00
const srcBucketName = 'bucket1';
exports.copyFile = functions.storage.bucket(srcBucketName).object().onFinalize((object) => {
const Storage = require('@google-cloud/storage');
const storage = new Storage();
const srcFilename = object.name;
const destBucketName = 'bucket2';
const destFilename = 'file2';
storage
.bucket(srcBucketName)
.file(srcFilename)
.copy(storage.bucket(destBucketName).file(destFilename))
.then(() => {
console.log(
`gs://${srcBucketName}/${srcFilename} copied to gs://${destBucketName}/${destFilename}.`
);
return console.log('done!');
})
.catch(err => {
console.error('ERROR:', err);
})
});https://stackoverflow.com/questions/51511851
复制相似问题