I am Trying to upload JSON data to gcs. As I did not use google cloud previously I started with uploading random String to gcs but I got stuck at the beginning itself while creating a Storage service object
Maven dependency
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-storage</artifactId>
<version>1.70.0</version>
</dependency>
import com.google.cloud.storage.*;
Storage storage = StorageOptions.getDefaultInstance().getService();
BlobId blobId = BlobId.of("bucket_name", "test_upload/test.txt");
BlobInfo blobInfo = BlobInfo.newBuilder(blobId).setContentType("text/plain").build();
Blob blob = storage.create(blobInfo, "Hello, Cloud Storage!".getBytes(UTF_8));
System.out.println(blob);
Compile Time Error:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project gcshelper: Compilation failure: Compilation failure:
ERROR] /Users/v3/gcshelper/src/main/java/com/tv/gcs/GcsTest.java:[16,41] cannot access com.google.cloud.ServiceOptions [ERROR] class file for com.google.cloud.ServiceOptions not found [ERROR] /Users/v3/gcshelper/src/main/java/com/tv/gcs/GcsTest.java:[19,28] cannot access com.google.cloud.Service [ERROR] class file for com.google.cloud.Service not found [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging.