我正在尝试从 GAE 中的“上传成功”处理程序中获取文件内容。文件上传到url:
blobstoreService.createUploadUrl("/onupload", uploadOptions));
所以,在 中/onupload
,我正在做这样的事情:
BlobKey myFile = context.getRequestBlobs().get("myFile").get(0);
然后我试过了:
InputStream is = new BlobstoreInputStream(myFile);
// .. read the stream
失败了com.google.appengine.api.blobstore.BlobstoreInputStream$BlobstoreIOException: BlobstoreInputStream received an invalid blob key: =?ISO-8859-1?Q?AMIfv96J=2DsyIbhm5=5FET?=
和
FileReadChannel ch = fileService.openReadChannel(myFile, false);
失败了
java.io.IOException
at com.google.appengine.api.files.FileServiceImpl.translateException(FileServiceImpl.java:615)
at com.google.appengine.api.files.FileServiceImpl.makeSyncCall(FileServiceImpl.java:588)
at com.google.appengine.api.files.FileServiceImpl.open(FileServiceImpl.java:521)
at com.google.appengine.api.files.FileServiceImpl.openForRead(FileServiceImpl.java:481)
at com.google.appengine.api.files.FileServiceImpl.openForRead(FileServiceImpl.java:473)
at com.google.appengine.api.files.FileServiceImpl.openReadChannel(FileServiceImpl.java:197)
关于我做错了什么的任何想法,是否有可能在上传处理程序中读取文件的内容?
请注意,对于 blobstore fs(不是 GS),它运行良好。