Closed GoogleCodeExporter closed 9 years ago
In the .NET Client library, MediaDownloader.cs, DownloadCore method, i
commented out builder.AddParameter(RequestParameterType.Query, "alt", "media");
and that appears to have resolved the download issue. Could someone point me to
documentation explaining the purpose of this parameter or why commenting out
this line would resolve the issue?
Original comment by u...@ftitech.mygbiz.com
on 26 Aug 2013 at 2:31
You should use "alt"="media", because only in that way you will get the file
itself and not its metadata.
Can you try again? The sample works for me.
If it still doesn't work, can you please attach Fiddler output to this Issue?
Thanks
Original comment by pele...@google.com
on 27 Aug 2013 at 1:14
Original comment by pele...@google.com
on 27 Aug 2013 at 1:14
Hi Peleyal,
For some reason, without the "alt"="media" parameter I was able to download the
file.
As you requested, I'll send you Fiddler output with and without the parameter
added to the code.
Original comment by u...@ftitech.mygbiz.com
on 27 Aug 2013 at 1:31
I've attached two Fiddler traces containing the activity around initiating the
download:
- SuccessfulUploadFailedDownloadMediaParamSetBrief.saz showing the failed
download and 302 redirect. A 1k file placeholder is created on the target, but
the file is empty. In this case, the media parameter is set.
- SuccessfulUploadAndDownloadMediaParamRemovedBrief.saz showing the successful
download. I am able to open the file on the target following the download. In
this case, the media parameter is not set.
Original comment by u...@ftitech.mygbiz.com
on 27 Aug 2013 at 2:21
Attachments:
Original comment by pele...@google.com
on 27 Aug 2013 at 7:22
Can you please check what happen if you change the number of tries in the
HttpConfigurableHandler?
You can do so, by the following snippet:
class MyInitializer : IConfigurableHttpClientInitializer
{
public void Initialize(ConfigurableHttpClient httpClient)
{
httpClient.MessageHandler.NumTries = 10;
}
}
and when you create your service, add this initializer, as following:
var service = new DriveService(new BaseClientService.Initializer()
{
Authenticator = auth,
ApplicationName = "YOUR_APP_NAME_HERE",
HttpClientInitializer = new MyInitializer();
});
If it will work, we may add another parameter to HttpConfigurableMessageHandler
that will store the number of redirect allowed.
Thanks,
looking forward to your response.
Original comment by pele...@google.com
on 14 Sep 2013 at 1:18
Original comment by pele...@google.com
on 14 Sep 2013 at 1:18
https://codereview.appspot.com/13480044/
Original comment by pele...@google.com
on 14 Sep 2013 at 1:52
To start, we implemented the change you suggested (setting NumTries to 10 in
the MessageHandler) and that seemed to do the trick with the
builder.AddParameter(RequestParameterType.Query, "alt", "media") code in place
in the MediaDownloader. Thank you for your help with this.
Can you explain why setting NumTries to 10 would resolve the issue? Is it
because there were more redirects that occur during download that needed to be
handled? If so, is there a static number to be expected or is it based on the
size of the download?
Finally, on a related note, does the MediaDownloader work with Google Docs that
actually require export to some format for download or do we have to stick with
the Google Docs API that has been deprecated?
Thanks,
Ethan
Original comment by ethanwil...@gmail.com
on 18 Sep 2013 at 8:34
Exactly. They were too many redirects (more than 3). The current implementation
stops after only 3 tries. The attached CL
(https://codereview.appspot.com/13480044/) add another property
(NumRedirectTries).
You can review that CL, and let me know your thoughts.
Regarding your second question, the above CL contains a solution for that as
well.
Let me know and thanks for your feedback
Original comment by pele...@google.com
on 18 Sep 2013 at 8:56
Thanks for the update, Peleyal. Your changes look fine and we will get the
latest. Returning to my second question, I didn't see anything in the code that
indicates how you are specifically handling Google Docs that must be exported
to some format, such as Doc or PDF prior to being downloaded. It appears that
the only way to do that is to use the deprecated Google Docs API, as shown in
the download code on this page:
https://developers.google.com/google-apps/documents-list/#downloading_documents_
and_files.
Original comment by ethanwil...@gmail.com
on 19 Sep 2013 at 3:53
[deleted comment]
I'm not exactly familiar with the old way the docs work, but....
I checked in Google Explorer API how a file looks like. This is the output:
kind": "drive#file",
"id": "ID",
"selfLink": "https://content.googleapis.com/drive/v2/files/[ID]",
...
"title": "Introduction to the .NET client library",
"mimeType": "application/vnd.google-apps.presentation",
"labels": {
"starred": false,
"hidden": false,
"trashed": false,
"restricted": false,
"viewed": true
},
"createdDate": "2013-09-01T20:44:32.507Z",
"modifiedDate": "2013-09-05T15:11:46.149Z",
"modifiedByMeDate": "2013-09-05T15:11:46.149Z",
"lastViewedByMeDate": "2013-09-19T13:10:43.754Z",
"parents": [
{
"kind": "drive#parentReference",
"id": "0AKSq4G25HO_JUk9PVA",
"selfLink":
"https://content.googleapis.com/drive/v2/files/ID/parents/PARENT_ID",
"parentLink": "https://content.googleapis.com/drive/v2/files/PARENT_ID",
"isRoot": true
}
],
"exportLinks": {
"text/plain": "
https://docs.google.com/feeds/download/presentations/Export?id=ID&exportFormat=t
xt
",
"application/pdf": "
https://docs.google.com/feeds/download/presentations/Export?id=ID&exportFormat=p
df
",
"application/vnd.openxmlformats-officedocument.presentationml.presentation":
"
https://docs.google.com/feeds/download/presentations/Export?id=ID&exportFormat=p
ptx
"
},
...
"editable": true,
"copyable": true,
"writersCanShare": true,
"shared": true,
"appDataContents": false
},
As you can see the exportLinks contains a link to download the file as txt,
pdf, pptx. With my fix (In the mentioned CL) you will be able to download
those file using the MediaDownloader.
Does that answer your question?
Eyal
Original comment by pele...@google.com
on 19 Sep 2013 at 5:01
Yes and thanks again, Eyal. I sincerely appreciate your help.
Ethan
Original comment by ethanwil...@gmail.com
on 19 Sep 2013 at 6:06
NP.
Let me know if you have any other questions or suggestions.
thanks!
Eyal
Original comment by pele...@google.com
on 19 Sep 2013 at 6:14
Original comment by pele...@google.com
on 16 Oct 2013 at 10:05
Original issue reported on code.google.com by
u...@ftitech.mygbiz.com
on 23 Aug 2013 at 3:46