Cuzok
Cuzok

Reputation: 9

Uploading client's file from server (spring boot application deployed on compute engine) to google bucket

I am trying to upload my client's file from springboot application deployed on gcp compute engine to google bucket. Below code uploads that file into bucket but gives error:

Resource resource = resourceLoader.getResource(GCP_AUTHENTICATION_FILE);
InputStream dbAsStream = resource.getInputStream();
String bucketName = GCP_BUCKET_NAME;
Storage storage = StorageOptions.newBuilder().setCredentials(GoogleCredentials.fromStream(dbAsStream))
                .setProjectId(GCP_PROJECT_ID).build().getService();
BlobId blobId = BlobId.of(bucketName, fileName);
BlobInfo blobInfo = BlobInfo.newBuilder(blobId).build();
storage.create(blobInfo, ClientFile.getBytes());

Error:

Handler dispatch failed; nested exception is java.lang.NoSuchMethodError: 'com.google.api.client.util.DateTime com.google.api.services.storage.model.StorageObject.getCustomTime()'

Upvotes: 0

Views: 203

Answers (1)

rsalinas
rsalinas

Reputation: 1547

As mentioned by @Gavin, the GCP library you are using is expecting StorageObject to have a method getCustomTime that doesn't exist. Confirm if you have a mismatch between GCP and the version of the GCP library you are using.

Upvotes: 1

Related Questions