Reading PlayStore csv review files from Google storage bucket using Java App Engine

635 views Asked by At

This problem has stumped me for most part of my day.

BACKGROUND

I am attempting to read the Play Store reviews for my Apps via my own Google App Engine Java project. Now I am able to get the list of all the files using Google Cloud Storage client api (java). I can also read the meta for each of the csv files in that bucket and print it to the logs:

PROBLEM

I simply can't find a way to read the actual object and get the csv data. My java code snippet:

BUCKET_NAME = "pubsite_prod_rev_*******";
objectFileName = "reviews/reviews_*****_***.csv"

Storage.Objects.Get obj = client.objects().get(BUCKET_NAME, objectFileName);
InputStream is = obj.executeMediaAsInputStream();

Now when I print this inputstream, it tells me its GZIPInputStream (java.util.zip.GZIPInputStream@f0be2c). Converting this inputstream to byte[] or String (desired) does not work. And if I try to envelope it inside GZIPInputStream object using:

zis = new GZIPInputStream(is);

it throws ZipException : Not in GZIP format.

Metadata of the file:

"contentType": "text/csv; charset=utf-16le",
"contentEncoding": "gzip",

What wrong am I doing?

Sub Question: In the past I have successfully read text data from Google Cloud Storage using GcsService, but it does not seem to work with the Buckets which have the Play Store review csv files. Does anybody know if my Google App Engine project (connected to same Google developer account) can read these Buckets?

1

There are 1 answers

0
AAP On

Solved it using executeMedia() and parseAsString

HttpResponse response = obj.executeMedia();
response.parseAsString(); //works!!