在通过file.createWriteStream()传输到GCP时,获取ESOCKETTIMEOUT,ECONNRESET或套接字会挂载大文件。
在尝试通过Google云端function将大文件(> 50MB)上传到Google云端存储时,根据我设置的选项,我遇到了这些例外:
- 当设置请求选项'永远:错误'我得到:错误:套接字挂断
- 当设置请求选项'resumable:true'时,我得到:Error:write ECONNRESET
- 当设置请求选项“可恢复:错误”我得到:错误:ESOCKETTIMEDOUT可恢复:假
这是我使用的代码:
function uploadFile(bucketName, filename, data) { console.log("Starting uploading blob..."); const Storage = require('@google-cloud/storage'); console.log("Creating client..."); const storage = new Storage(); storage.interceptors.push({ request: function(reqOpts) { reqOpts.forever = false; return reqOpts } }); console.log("Getting bucket " + bucketName + "..."); const bucket = storage.bucket(bucketName); console.log("Creating file " + filename + "..."); const file = bucket.file(filename); console.log("Creating write stream..."); var writeStream = file.createWriteStream({ metadata: { contentType: 'plain/text' }, resumable: false }); writeStream.on('error', function(e) { console.error("An error occurred : " + e); }); writeStream.on('finish', function() { console.log("Success"); }); console.log("Initializing Streaming..."); var bufferStream = new stream.PassThrough(); bufferStream.end(data); bufferStream.pipe(writeStream); }
有什么我失踪?
- MongoLab上的Node.js和MongoDB:每个插入上的“套接字closures”
- 我应该使用REST API还是使用地理位置应用程序的Socket.io?
- swift – 我可以连接到socket.io服务器,但我不能发射事件
- 当从socket.io – node.js接收到消息时,从客户端播放audio
- 如何确保Sails.js中的蓝图访问
- 在socket.io中添加函数到socket的最佳方法是什么?
- 想要在android中使用node.js和socket.io发送图像
- 什么可以做node.js或socket.io?
- 什么因素导致数据在python(或python / node.js)的套接字中不通过?