1

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

2 Answers 2

1

You could use MediaStreamSource instead of MediaFileSource.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanx @BalusC , everything is working fine till I get this ServiceException that says "Not authorized to write to this feed"
com.google.gdata.util.ServiceForbiddenException: OK Not authorized to write to this feed
1

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.

2 Comments

I would prefer to upload directly from stream object, is it possible to customize the MediaFileSource in any way so that it takes *stream object
Did you look at the code of gaefs servlet? It reads from a stream. You may also read App Engine docs: code.google.com/appengine/kb/java.html#fileforms

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.