aws-sdk client-s3 上传:chrome 上传 8 GB 后崩溃

aws-sdk client-s3 Upload: chrome crash after 8 GB of upload

我想从浏览器上传一个 17 GB 的文件,但是在 8 GB 之后 chrome 由于内存耗尽而崩溃

import { PutObjectCommandInput, S3Client } from '@aws-sdk/client-s3';
import { Progress, Upload } from "@aws-sdk/lib-storage";

const uploadParams: PutObjectCommandInput = {
  Bucket: 'my-bucket',
  Key: 'my-file',
  Body: file, // is File from <input type="file">
};

const upload: Upload = new Upload({
  client: s3Client,
  params: uploadParams,
});

// start upload
await upload.done();

我做错了什么?

AWS S3 在单个 PUT 操作上有 5GB size limit

您需要在上传前启动 multi-part upload 并将文件分成块(例如 5GB)- 这 可能 也可以解决您的 Chrome 崩溃问题.

即使 Chrome 没有崩溃,您的代码也不会按原样运行 - 将文件分块并一个一个上传。