wnds / google-api-java-client

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

Request InputStream/SeekableStream Media Downloader #633

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
External references, such as a standards document, or specification?
http://docs.oracle.com/cd/E17802_01/products/products/java-media/jai/forDevelope
rs/jai-apidocs/com/sun/media/jai/codec/SeekableStream.html
http://docs.oracle.com/javase/1.3/docs/api/java/io/InputStream.html

Java environments (e.g. Java 6, Android 2.3, App Engine, or All)?
Java 6, non-App Engine (at least for large requests)

Please describe the feature requested.

Instead of having an output sink to write bytes into, an app might prefer to 
have an input stream to read bytes out of, possibly making non-sequential 
access and multiple underlying HTTP requests to the web API for the data, and 
have it all happen just-in-time with some caching policy (i.e., cache all the 
file data, none of the data, last n KB of requests) and some capture policy 
(e.g., always the most recent version, or locked to a particular version & 
throw an exception otherwise -- using If-Match to ensure).

It would be great if you could turn a resource id into a SeekableStream that 
would then not make any requests for data until someone calls read on it. It 
would be nice if it also had knobs for caching (cache all reads | last n B of 
reads | only in m B chunks | preload all | preload first l B) and for resource 
expiration (e.g., if the resource is modified/deleted and the SeekableStream 
has to go to the service for more data -- perhaps it throws some kind of 
exception in those cases, or rather it flows gracefully to the next version) 
and handles all the retryable failures that might transpire (using the retry 
policy).

Original issue reported on code.google.com by nherr...@google.com on 16 Oct 2012 at 8:54

GoogleCodeExporter commented 9 years ago
Added executeMediaAsInputStream() that returns java.io.InputStream that should 
help with part of this:
https://codereview.appspot.com/6725045/

I also filed a feature request to specify the Range header in 
HttpMediaDownloader
https://code.google.com/p/google-api-java-client/issues/detail?id=634

Of course you can also just call getRequestHeaders().setRange("bytes=100-199")

With respect to SeekableStream: can you please provide sample code that 
demonstrates how this might be used with respect to HTTP requests?  I'm not 
familiar with this.  Without really investigating this, my gut feeling is this 
may be outside the scope of what we may want to provide in this library.

Original comment by yan...@google.com on 16 Oct 2012 at 10:11