Google App Engine 中 blobstore 对象的 1MB 配额限制?
我正在使用 App Engine(版本 1.4.3)直接编写blobstore 以保存图像。 当我尝试存储大于 1MB 的图像时,出现以下异常
com.google.apphosting.api.ApiProxy$RequestTooLargeException: The request to API call datastore_v3.Put() was too large.
我认为 每个对象的限制是2GB
这是存储图像的Java代码
private void putInBlobStore(final String mimeType, final byte[] data) throws IOException {
final FileService fileService = FileServiceFactory.getFileService();
final AppEngineFile file = fileService.createNewBlobFile(mimeType);
final FileWriteChannel writeChannel = fileService.openWriteChannel(file, true);
writeChannel.write(ByteBuffer.wrap(data));
writeChannel.closeFinally();
}
I'm using App Engine (version 1.4.3) direct write the blobstore in order to save images.
when I try to store an image which is larger than 1MB I get the following Exception
com.google.apphosting.api.ApiProxy$RequestTooLargeException: The request to API call datastore_v3.Put() was too large.
I thought that the limit for each object is 2GB
Here is the Java code that stores the image
private void putInBlobStore(final String mimeType, final byte[] data) throws IOException {
final FileService fileService = FileServiceFactory.getFileService();
final AppEngineFile file = fileService.createNewBlobFile(mimeType);
final FileWriteChannel writeChannel = fileService.openWriteChannel(file, true);
writeChannel.write(ByteBuffer.wrap(data));
writeChannel.closeFinally();
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
以下是我读取和写入大文件的方法:
Here is how I read and write large files:
最大对象大小为 2 GB,但每个 API 调用最多只能处理 1 MB。至少对于阅读来说是这样,但我认为对于写作来说可能也是如此。因此,您可以尝试将对象的写入拆分为 1 MB 的块,看看是否有帮助。
The maximum object size is 2 GB but each API call can only handle a maximum of 1 MB. At least for reading, but I assume it may be the same for writing. So you might try to split your writing of the object into 1 MB chunks and see if that helps.
正如布鲁莫上面所建议的,如果你把它分成块< 1MB就可以了。这是一些代码。
As Brummo suggested above if you split it into chunks < 1MB it works. Here's some code.