【问题标题】:App Engine Cloud Storage RequestPayloadTooLargeException file exceeded the 10 MB limitApp Engine Cloud Storage RequestPayloadTooLargeException 文件超出了 10 MB 的限制
【发布时间】:2018-09-25 06:46:00
【问题描述】:

我们正在尝试将文件上传到 App Engine Standard Java 7 上的 Google Cloud Storage。

一切正常,除了大于 10 MB 的文件。当我们尝试上传此类文件时,会出现异常:

com.google.appengine.api.urlfetch.RequestPayloadTooLargeException: The request to https://www.googleapis.com/upload/storage/v1/b/filestoragetradeos1/o?projection=full&uploadType=multipart exceeded the 10 MiB limit.
at com.google.appengine.api.urlfetch.URLFetchServiceImpl.convertApplicationException(URLFetchServiceImpl.java:151)
at 

我们使用的代码:

public Blob createFile(String fileName, InputStream inputStream) throws IOException {

    String bucketName = TSystemUtils.getStorageBucketName();//just a bucket name

    List<Acl> acls = new ArrayList<>();
    acls.add(Acl.of(Acl.User.ofAllAuthenticatedUsers(), Acl.Role.READER));

    byte[] bytes = IOUtils.toByteArray(inputStream);//apache IO library
    Storage storage = StorageOptions.getDefaultInstance().getService();
    Blob blob = storage.create(BlobInfo.newBuilder(bucketName, (UUID.randomUUID() + "/" + fileName)).setAcl(acls).build(), bytes);

    return blob;
}

现在,App Engine 使用 URL Fetch 来执行所有 HTTP 请求,它有一个10 MB Request size limit

有没有办法将比 App Engine Standard Java 7 上更大的文件上传到 Google Cloud Storage?

【问题讨论】:

    标签: java google-app-engine google-cloud-platform google-cloud-storage


    【解决方案1】:

    您可以使用signed URLs 将大文件从客户端上传到云存储。您的 App Engine 应用程序将生成一个签名 URL 并将其传递给客户端以启动上传。你甚至可以轻松实现resumable uploads

    【讨论】:

      猜你喜欢
      • 2015-07-07
      • 1970-01-01
      • 1970-01-01
      • 2015-09-29
      • 2011-07-02
      • 2019-09-28
      • 2013-01-26
      • 2020-03-24
      • 2016-01-24
      相关资源
      最近更新 更多