我们正在尝试将文件上传到App Engine Standard Java 7上的Google Cloud Storage。
除了大于10MB的文件之外,一切都运行正常。当我们尝试上传这样的文件时,我们得到了一个异常:
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?
发布于 2018-04-15 21:39:36
您可以使用signed URLs将大文件从客户端上传到云硬盘。您的App Engine应用程序将生成一个签名的URL,并将其传递给客户端以启动上传。您甚至可以轻松地实现resumable uploads
https://stackoverflow.com/questions/49841873
复制相似问题