在GAE java中使用inputstream上传文件

发布于 2024-08-11 16:59:01 字数 354 浏览 3 评论 0原文

我正在尝试将文件上传到谷歌网站,并使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

落在眉间の轻吻 2024-08-18 16:59:01

您可以使用 MediaStreamSource< /code>而不是 MediaFileSource

You could use MediaStreamSource instead of MediaFileSource.

聊慰 2024-08-18 16:59:01

您对 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文