Search code examples
javagoogle-app-enginefile-uploadapache-commons-fileupload

upload file using inputstream in GAE java


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));

Solution

  • You could use MediaStreamSource instead of MediaFileSource.