7
我正在使用nodejs将文件上传到aws服务器。并发现文件大小不正确。我得到2.1KB。Streaming-s3不能正确升级文件以正确
这里是我的代码
var uploadFile = function (fileReadStream, awsHeader, cb) {
//set options for the streaming module
var options = {
concurrentParts: 2,
waitTime: 20000,
retries: 2,
maxPartSize: 10 * 1024 * 1024
};
//call stream function to upload the file to s3
var uploader = new streamingS3(fileReadStream, config.aws.accessKey, config.aws.secretKey, awsHeader, options);
//start uploading
uploader.begin();// important if callback not provided.
// handle these functions
uploader.on('data', function (bytesRead) {
//console.log(bytesRead, ' bytes read.');
});
uploader.on('part', function (number) {
//console.log('Part ', number, ' uploaded.');
});
// All parts uploaded, but upload not yet acknowledged.
uploader.on('uploaded', function (stats) {
//console.log('Upload stats: ', stats);
});
uploader.on('finished', function (response, stats) {
console.log(response);
cb(null, response);
});
uploader.on('error', function (err) {
console.log('Upload error: ', err);
cb(err);
});
};
虽然,我在AWS斗了文件名。但后来我尝试打开它说失败的文件。
我试图从URL上传这个文件:https://arxiv.org/pdf/1701.00003.pdf
任何建议吗?
谢谢
: - 我只有当我使用上述代码doign时,在该URL中出现问题。现在项目已经完成,没有任何要改变的代码 –
你能告诉我上面的代码有什么问题吗? –