【发布时间】: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