无法上传大于500Mb的.tar.gz文件

问题描述 投票:0回答:1

我想使用 javascript 将 .tar.gz 文件(>500mb)上传到 URL。

这是我的方法

async uploadMapFile(url, FilePath, mapType) {
  try {
    let body = await _fs.promises.readFile(FilePath);
    let contentType =
      mapType === "navi" ? "application/zip" : "application/tar+gzip";
    const { data } = await axios.put(url, body, {
      headers: {
        "Access-Control-Allow-Origin": process.env.APP_ORIGIN,
        "Content-Type": contentType,
        "Access-Control-Allow-Methods": "*",
        "Access-Control-Allow-Credentials": "true"
      }
    });

    console.log("After uploading file", data, mapType);
    //Removing the uploaded folder
    await this.afterFileUpload(mapType);
    this.store.mapUploadFlag = false;
  } catch (error) {
    console.log(error);
    this.store.mapUploadFailed = true;
  }
},

使用上面的代码我可以上传较小的文件,但无法上传较大的文件。 如果文件较大,应用程序会崩溃。

reactjs vue.js axios javascript-objects
1个回答
0
投票

Chrome 似乎有 500mb 的 Blob 限制,将请求大小限制在 500mb 左右。请参阅此铬问题

© www.soinside.com 2019 - 2024. All rights reserved.