Uploading a pdf saved on Blobstore to Google Docs

168 views
Skip to first unread message

Iaco86

unread,
Jan 6, 2012, 8:11:32 AM1/6/12
to Google App Engine
Hi,
I wrote a web app for a university course, thanks to which users could
upload file (pdfs mainly, no bigger than 10 Mb) on the blobstore.

Then users could choose to sync those docs with their Google Docs
account. This worked fine till Google deprecated the old upload
method, forcing to use the resumable upload method.

I am trying to achieve this using GData, but i cannot really make it.
Is it even possible, or should i give up for the moment?

Thanks.
Cheers,
Iacopo

Ernesto Oltra

unread,
Jan 7, 2012, 6:00:21 AM1/7/12
to google-a...@googlegroups.com
Hi,

I've just finished today implementing a resumable uploader in my app, from blobstore to google docs. It's possible, it works and it's the best way. If you found it easier you can upload all the file at once with resumable upload too, but any little problem will make the entire upload fail (and not a little chunk).

Ernesto

newdeveloper

unread,
Jan 9, 2012, 11:21:13 AM1/9/12
to Google App Engine
I'm very new to GAE. Could you anyone kindly show me how to upload a
PDF file from blobstore to google docs in Java? Thanks.

Alessandro Aglietti

unread,
Jan 9, 2012, 11:45:38 AM1/9/12
to google-a...@googlegroups.com
Hi, I use this code for upload a csv file and convert it.

//1) Get input stream from a blobstore file and the blobinfo metas

final BlobInfo blobInfo = new BlobInfoFactory().loadBlobInfo(blobKey);

BlobstoreInputStream blobStoreReader = null;

try {

blobStoreReader = new BlobstoreInputStream(blobKey);

} catch (IOException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

//2) create a new document list entry

DocumentListEntry newDocument = new DocumentListEntry();

// 3) set the inputstream as a source for the new document entry

newDocument.setMediaSource(new MediaStreamSource(blobStoreReader, 
blobInfo.getContentType()));

newDocument.setTitle(new PlainTextConstruct(
blobInfo.getFilename()));

// 4) upload - feedUrl > https://docs.google.com/feeds/myu...@email.ext/private/full?convert=false

DocsService client = new DocsService("BlobStore2Docs");

client.insert(feedUrl, newDocument);

Excuse for the spaghetti code ^^

I hope this useful for you.

Cheers

PS: If you are interested I've developed a "BlobStore2Docs.java" that resolve the problem. If you want contact me for any reason.



--
You received this message because you are subscribed to the Google Groups "Google App Engine" group.
To post to this group, send email to google-a...@googlegroups.com.
To unsubscribe from this group, send email to google-appengi...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en.




--
Alessandro Aglietti

webLog - realtimeCV - Google+

"Gli'è ora d'illuminassi, tirassi sui i calzoni e levassi"

Reply all
Reply to author
Forward
0 new messages