开发者

upload file using inputstream in GAE java

开发者 https://www.devze.com 2022-12-11 12:48 出处:网络
I am trying to upload file to google sites and am obtaining the stream using apache commons file upload.

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 conv开发者_高级运维erted file.

AttachmentEntry newAttachment = new AttachmentEntry();
newAttachment.setMediaSource(new MediaFileSource(file, fileMimeType));


You could use MediaStreamSource instead of MediaFileSource.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消