简体   繁体   English

Express js中的AWS s3文件上传:上传与分段上传之间有什么区别

[英]AWS s3 file upload in express js: whats the difference between upload vs multipart upload

I am trying to upload a file to AWS s3 using express js,instead of putObject i am using upload http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#upload-property function 我正在尝试使用Express js而不是putObject将文件上传到AWS s3,而是使用upload http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#upload-property函数

       var options ={
            partSize: 5242880, queueSize: 1
        };
        console.time('Uploadtime');
        s3.upload(params,options,function(err, data) {
            if (err) console.log(err, err.stack); // an error occurred
            else     {
                console.timeEnd('Uploadtime');
                console.log("uploaded",data);
                res.json({
                    'status':'Uploaded'
                });
            }           // successful response
        });

I think upload and multipart upload do the same thing(am i correct??) My question is do i need to use multi part upload or stay with upload method. 我认为上传和分段上传执行相同的操作(我正确吗?)我的问题是我需要使用分段上传还是保持upload方式。

From the docs i can't get the similarities between upload and multipartupload 从文档中我无法获得上载和multipartupload之间的相似之处

upload and multipart upload perform the same action but there are the few advantage of multipart upload 上载和分段上传执行相同的操作,但是分段上传有一些优势

  1. You can upload parts in parallel to improve throughput. 您可以并行上传零件以提高吞吐量。

  2. Smaller part size minimizes the impact of restarting a failed upload due to a network error. 较小的部件尺寸可将由于网络错误而重新启动失败的上传的影响降至最低。

  3. You can upload object parts over time. 您可以随时间上载对象零件。 Once you initiate a multipart upload 一旦开始分段上传

  4. there is no expiry; 没有到期日; you must explicitly complete or abort the multipart upload. 您必须明确完成或中止分段上传。

  5. You can upload an object as you are creating it. 您可以在创建对象时上载对象。

So you can decide which one you should go with according to your need , multipart is recommended when the object you are uploading is big in size . 因此,您可以根据自己的需要决定使用哪一个,当要上传的对象较大时,建议使用多部分。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM