debbiereid / google-api-java-client

Automatically exported from code.google.com/p/google-api-java-client
0 stars 0 forks source link

Drive.Files.Get getMediaHttpDownloader() returns null #906

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Version of google-api-java-client (e.g. 1.15.0-rc)?
1.17.0-rc and 1.18.0-rc

Java environment (e.g. Java 6, Android 2.3, App Engine)?
Java 7 with App Engine SDK 1.9.10

Describe the problem.
Following the example for the Resumable Media Download:
Drive.Files.Get request = drive.files().get(fileId);
request.getMediaHttpDownloader().setProgressListener(new 
CustomProgressListener());
request.executeMediaAndDownloadTo(out);

I get a NPE because request.getMediaHttpDownloader() returns null.

How would you expect it to be fixed?
There is a protected method initializeMediaDownload() under 
AbstractGoogleClientRequest that should be called perhaps?

I was looking into the Remote class under Drive and when get(String fileId) is 
called the Get constructor is calling initializeMediaDownload().

Original issue reported on code.google.com by bogdan.b...@appsbroker.com on 30 Sep 2014 at 10:50

GoogleCodeExporter commented 9 years ago
I was not able to reproduce, but in case you are still getting NPE, you get 
create a MediaHttpDownloader manually like the following:

MediaHttpDownloader downloader =
        new MediaHttpDownloader(httpTransport, drive.getRequestFactory().getInitializer());
    downloader.setProgressListener(new FileDownloadProgressListener());
    downloader.download(new GenericUrl(uploadedFile.getDownloadUrl()), out);

See the drive sample for more details:

https://code.google.com/p/google-api-java-client/source/browse/drive-cmdline-sam
ple/src/main/java/com/google/api/services/samples/drive/cmdline/DriveSample.java
?repo=samples

Original comment by wonder...@google.com on 29 Dec 2014 at 7:43