'Read an object from Google Cloud Storage in Java
I am using the Google Cloud Storage API ver 2.6.1, and all the examples in the SO/most Google searched websites/Google own sample codes, etc seem to be using either of the following two sequences :
Storage storage = StorageOptions.newBuilder()
.setProjectId(projectId)
.setCredentials(GoogleCredentials.fromStream(newFileInputStream(serviceAccountJSON)))
.build()
.getService();
or, with the environment variable for access credentials defined,
Storage storage = StorageOptions.getDefaultInstance()
.getService();
The problem is that the Class newbuilder() does not have neither .setProjectID, nor does getdefaultinstance() have a .getService().
My intent is to test if an object is present in a specific bucket, and if present download it to either memory or to a local file.
More updates : I went to the specifications given by @pringi and then located the guava-31.1-jre.jar, and installed it in the Project Structure. No joy.. the statement (and those following it) all show .cloud as red
import com.google.cloud.storage.Bucket;
Then I took the IntelliJ recommendation and had to install cloud code, which in turn installed another copy of google cloud SDK and created a whole new security key but I am still not able to get the 4 line example code work.
How do I go about doing this ? Thanks for your attention.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
