Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HttpResponse.download(OutputStream) #81

Closed
wonderfly opened this issue Jan 9, 2015 · 2 comments
Closed

HttpResponse.download(OutputStream) #81

wonderfly opened this issue Jan 9, 2015 · 2 comments
Assignees
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Comments

@wonderfly
Copy link
Contributor

From yan...@google.com on April 07, 2012 05:34:29

External references, such as a standards document, or specification? http://stackoverflow.com/questions/9941378/how-to-download-a-large-file-using-google-api-java-client-on-android http://javadoc.google-http-java-client.googlecode.com/hg/1.8.3-beta/com/google/api/client/http/HttpResponse.html Java environments (e.g. Java 6, Android 2.3, App Engine, or All)? All Please describe the feature requested. Here's an idea: suppose you want to just download the content of a response into a file, e.g. if you are downloading an image. A good way to do it is to use AbstractInputStreamContent.copy as in this example:

HttpTransport transport = new NetHttpTransport();
HttpRequestFactory requestFactory = transport.createRequestFactory();
HttpRequest request =
    requestFactory.buildGetRequest(new GenericUrl(
        " https://www.google.com/images/srpr/logo3w.png")); OutputStream outputStream =
    new FileOutputStream(new File("/tmp/logo3w.png"));
HttpResponse response = request.execute();
InputStream inputStream = response.getContent();
AbstractInputStreamContent.copy(inputStream, outputStream, true);

Unfortunately, AbstractInputStreamContent.copy is hard to discover. Perhaps we can make it easier to find by adding an HttpResponse.download(OutputStream) method, so now the last 2 lines would now be:

response.download(outputStream);

We could also potentially add something similar in JsonHttpRequest and JsonHttpClient.

Original issue: http://code.google.com/p/google-http-java-client/issues/detail?id=81

@wonderfly wonderfly added type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. imported priority: p2 Moderately-important priority. Fix may not be included in next release. labels Jan 9, 2015
@wonderfly wonderfly self-assigned this Jan 9, 2015
@wonderfly
Copy link
Contributor Author

From rmis...@google.com on April 09, 2012 05:56:34

This idea sounds good to me.
Sent out http://codereview.appspot.com/5985069/

Status: Started

@wonderfly
Copy link
Contributor Author

From rmis...@google.com on April 11, 2012 07:57:06

Status: Fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.
Projects
None yet
Development

No branches or pull requests

1 participant