I\'m developping an application that provides users with an interface where they can download files from our Google Cloud Storage. I wrote unit tests and I could connect to
@AnandMohan is correct. You just have to make copy on "tmp" folder because all the locations are read only, just "tmp" is writable. Check below:
Storage storage = StorageOptions.newBuilder().setProjectId(PROJECT_ID).build().getService();
Blob blob = storage.get(BUCKET_NAME, fileName);
ReadChannel readChannel = blob.reader();
File file = new File("/tmp/" + FILE_NAME);
FileOutputStream fileOuputStream = new FileOutputStream(file);
fileOuputStream.getChannel().transferFrom(readChannel, 0, Long.MAX_VALUE);
fileOuputStream.close();
// Now file is ready to send whereever you want