In my web project web .net I try to implement google docs.
I upload any MS office document and view it on telerik window by open window sets url: entry.AlternateUri.ToString()
Then I try to download file (if title is match) to local:
myService = new DocumentsService("exampleCo-exampleApp-1");
myService.setUserCredentials(开发者_StackOverflow"name_my_mail@gmail.com", "pass");
DocumentsListQuery query = new DocumentsListQuery();
DocumentsFeed feed = myService.Query(query);
foreach (DocumentEntry entry in feed.Entries)
{
if (entry.Title.Text == "temp.docx")
{
Uri documentUri = new Uri(entry.Content.AbsoluteUri);
HttpWebRequest webRequest = (HttpWebRequest)HttpWebRequest.Create(documentUri);
GDataGAuthRequestFactory factory = (GDataGAuthRequestFactory)myService.RequestFactory;
webRequest.Headers.Add("Authorization", "GoogleLogin auth=" + factory.GAuthToken);
HttpWebResponse webResponse = (HttpWebResponse)webRequest.GetResponse();
StreamReader streamReader = new StreamReader(webResponse.GetResponseStream());
StreamWriter streamWriter = new StreamWriter("D:\\temp.txt");
string line = "";
while( (line = streamReader.ReadLine()) != null) {
streamWriter.WriteLine(line);
}
streamReader.Close();
streamWriter.Close();
}
}
But file temp.txt contents actual html code of content file fron google acount.
You might wanna check out Google Docs API.
DotNet API
General Google Docs API
Hope that helps
Cheers
Sascha
精彩评论