简体   繁体   English

通过预签名 URL 将视频上传到 S3 的最佳方式?

[英]Best way to upload video via a presigned URL to S3?

I'm wondering what the best way is to upload a video to S3 via a presigned URL. I am primarily considering using a standard HTTP PUT request, placing video/mp4 as the Content-Type , and then attaching the video file as the body.我想知道通过预签名的 URL 将视频上传到 S3 的最佳方法是什么。我主要考虑使用标准的 HTTP PUT 请求,将video/mp4作为Content-Type ,然后将视频文件作为正文附加.

I'm wondering if there are more efficient approaches to doing this, such as using a third party library or possibly compressing the video before sending it via the PUT request?我想知道是否有更有效的方法来执行此操作,例如使用第三方库或可能在通过 PUT 请求发送视频之前压缩视频?

In general, when your object size reaches 100 MB, you should consider using multipart uploads instead of uploading the object in a single operation.通常,当您的 object 大小达到 100 MB 时,您应该考虑使用分段上传,而不是一次上传 object。

https://docs.aws.amazon.com/AmazonS3/latest/userguide/mpuoverview.html https://docs.aws.amazon.com/AmazonS3/latest/userguide/mpuoverview.html

I had most success using Uppy for this为此,我使用 Uppy 取得了最大的成功

https://uppy.io/docs/aws-s3-multipart/ https://uppy.io/docs/aws-s3-multipart/

You will need to provide some backend endpoints though:不过,您需要提供一些后端端点:

  1. https://uppy.io/docs/aws-s3-multipart/#createMultipartUpload-file https://uppy.io/docs/aws-s3-multipart/#createMultipartUpload-文件
  2. https://uppy.io/docs/aws-s3-multipart/#listParts-file-uploadId-key https://uppy.io/docs/aws-s3-multipart/#listParts-file-uploadId-key
  3. https://uppy.io/docs/aws-s3-multipart/#prepareUploadParts-file-partData https://uppy.io/docs/aws-s3-multipart/#prepareUploadParts-file-partData
  4. https://uppy.io/docs/aws-s3-multipart/#abortMultipartUpload-file-uploadId-key https://uppy.io/docs/aws-s3-multipart/#abortMultipartUpload-file-uploadId-key
  5. https://uppy.io/docs/aws-s3-multipart/#completeMultipartUpload-file-uploadId-key-parts https://uppy.io/docs/aws-s3-multipart/#completeMultipartUpload-file-uploadId-key-parts

On compression part of you question, S3 does not have any compute.关于你问题的压缩部分,S3 没有任何计算。 It will not modify your sent bytes, it will just store it.它不会修改您发送的字节,它只会存储它。 If want to use compression, you need to do that before upload, upload to cloud, unzip there with some compute (Ec2, Lambda etc.) and then put to S3.如果要使用压缩,您需要在上传之前执行此操作,上传到云端,在那里使用一些计算(Ec2、Lambda 等)解压缩,然后放入 S3。

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

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