我有一个由google.storage.object.finalize
上的存储桶触发的云功能。在此功能中,我下载了触发该功能的文件,并对数据进行了一些转换。如果此文件为〜5KB,则函数将按预期执行。如果文件约为200MB,则file.download
回调将永远不会运行,并且Stackdriver除了Function execution took 14 ms,finished with status: 'ok'
之外什么都不会显示。
我了解通过HTTP上传到HTTP触发功能的文件有10MB的限制,但是此功能是由Cloud Storage触发的。对this question的回答指出,存储触发功能没有施加10MB的限制,因此我怀疑可能存在超时问题。
该功能设置为2GB的内存限制,超时时间为5分钟,并且所有存储桶/功能都位于同一区域。当然,这将足够用于传输和处理200MB文件的资源(本地分析显示该过程在几秒钟内完成,而内存不足512MB)。
const { Storage } = require('@google-cloud/storage');
const storage = new Storage();
const uploadBucket = storage.bucket("<bucket name>");
module.exports = (data,context) => {
console.log('Getting file ref'); // Logged regardless of file size
const file = uploadBucket.file(<file name>);
file.download(function (err,buffer) {
console.log('Starting file processing');
// With a smaller file,this callback runs as expected.
// With larger files,this code is never reached.
});
};
我是否对该功能和存储桶之间的可用带宽有不正确的了解,或者这暗示了另一个问题?