East2West
East2West

Reputation: 667

Stream out with Java as BufferedReader Readline() from google cloud storage

I've been searching for java examples or java client libraries to stream out csv content from google blob storage and unfortunately no luck yet except app engine or python ones. We have an application and it uses CharStreams.readLines( ... ) to stream out the data and now that application should be up in compute engine with source data in storage.

Is it possible and if so any documentation?

Upvotes: 1

Views: 695

Answers (2)

East2West
East2West

Reputation: 667

I got perfect examples, actually libraries utilizing guava's bytesource and charsource;

https://github.com/zulily/gcs-buddy/tree/master/src/main/java/gcsbuddy

gcs-buddy An easy-to-use java client for the Google Cloud Storage (GCS) API.

Features

automatic retry on qualifying API errors simplified object and prefix iteration upload/download progress monitoring ability to read objects directly using Guava's ByteSource and CharSource convenience functions for identifying "implicit directories", composing objects, and more

Upvotes: 1

jterrace
jterrace

Reputation: 67063

Take a look at the getObjectData function in the storage sample here:

https://code.google.com/p/google-api-java-client/source/browse/storage-cmdline-sample/src/main/java/com/google/api/services/samples/storage/cmdline/StorageSample.java?repo=samples#477

Instead of using the executeMediaAndDownloadTo function, use the executeMediaAsInputStream function instead. This will return an InputStream instance, which you should be able to pass to CharStreams.readLines.

Upvotes: 1

Related Questions