Downloading From Google Docs
Posted
by jeremynealbrown
on Stack Overflow
See other posts from Stack Overflow
or by jeremynealbrown
Published on 2010-05-11T18:40:18Z
Indexed on
2010/05/11
18:44 UTC
Read the original article
Hit count: 196
Hello,
I am using the gdata-java-client Version 2 with for and Android app that allows users to download documents from their Google Docs account. Currently I am able to authenticate, request and display a list of all the user's documents. From here I would like to open each type of document in a specific Activity. If it's a spreadsheet or a csv file, open it in one activity and if it is a text document open it in another activity. This is where things are getting hazy. First I need to determine what type of document the user selected in order download the file in the appropriate format by appending exporFormat=(csv,xls,doc,txt)
to the query string. I don't see any indication in the original list of documents as to what kind of file the each entry is.
Secondly as a test I can just append a raw string to the end of the query string. As an example, a query might look like this:
https://spreadsheets.google.com/feeds/download/spreadsheets/Export?key=0AsE_6_YIr797dHBTUWlHMUFXeTV4ZzJlUGxWRnJXanc&exportFormat=xls
Notice that at the end of the string is the hardcoded export format. This query returns a HTTPResponse with a 200 OK message. However if I look at the response.content or use response.parseAsString I see what appears to be a Google Docs home page has html text.
I don't get this result when I try to download a text document. When I request a text document the response.content is the body of the text file.
If I copy and paste this uri into a browser I get the requested file as a download.
To summarize, this question is two-fold: 1. How do I determine the type( plain text, .doc, .csv, .xls ) of a document from the initial list of user documents. 2. How do I download the actual .csv or spreadsheet files?
Thanks in advance.
© Stack Overflow or respective owner