How do I access Google Cloud Storage from App Engine in an on-premises development environment?
My code works fine on deployed Google App Engine, but not when debugging it locally. The return value of GcsFileMetadata is null, and gcsService.openReadChannel (gcsFilename, 0) gives a FileNotFoundException, more details below. To summarize, the problem is that the local engine of the application cannot access google cloud storage. How to fix it? Any workarounds?
Here's the code
GcsFilename gcsFilename = new GcsFilename(BUCKET_NAME, progress.imageName);
GcsFileMetadata gcsFileMetadata = gcsService.getMetadata(gcsFilename);
if (gcsFileMetadata == null) throw new Exception("gcsService.getMetadata(gcsFilename) returned null");
int fileSize = (int) gcsFileMetadata.getLength();
ByteBuffer byteBuffer = ByteBuffer.allocate(5*1024*1024);
GcsInputChannel gcsInputChannel = gcsService.openReadChannel(gcsFilename, 0);
gcsInputChannel.read(byteBuffer);
gcsFileMetadata is null when debugging locally, but works fine when deployed. I will comment this out and I am getting the following error on this line:
GcsInputChannel gcsInputChannel = gcsService.openReadChannel(gcsFilename, 0);
Here's the error:
java.io.FileNotFoundException: com.google.appengine.tools.cloudstorage.dev.LocalRawGcsService@54381103: No such file: GcsFilename(cloudimagesbucketname, image_20150105_180444)
+3
source to share