在GAE java中使用inputstream上传文件
我正在尝试将文件上传到谷歌网站,并使用 apache commons 文件上传获取流。 我得到的输入流如下:
InputStream is = fileItem.openStream();
如何在文件对象中转换此输入流,以便下面的调用成功,并且我能够将 MediaFileSource 设置为上面转换的文件。
AttachmentEntry newAttachment = new AttachmentEntry();
newAttachment.setMediaSource(new MediaFileSource(file, fileMimeType));
I am trying to upload file to google sites and am obtaining the stream using apache commons file upload.
I get the input stream as under
InputStream is = fileItem.openStream();
How will I convert this input stream in file object so that below call succeeds and I am able to set the MediaFileSource to above converted file.
AttachmentEntry newAttachment = new AttachmentEntry();
newAttachment.setMediaSource(new MediaFileSource(file, fileMimeType));
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用
MediaStreamSource< /code>
而不是
MediaFileSource
。You could use
MediaStreamSource
instead ofMediaFileSource
.您对 AppEngine 上的文件系统没有写入权限,并且您应该将数据保存在数据存储中。不过,gaefs 项目为您提供了一个虚拟文件系统,据我所知, ,支持文件上传。
You have no write access to a file system on AppEngine and you're supposed to keep your data in datastore. However, gaefs project gives you a virtual file system and, as to the best pf my knowledge, supports file uploading.