将客户端的文件从服务器部署在计算引擎上的 Spring Boot 应用程序上传到谷歌存储桶

问题描述

我正在尝试将我的客户端文件从部署在 gcp 计算引擎上的 springboot 应用程序上传到谷歌存储桶。下面的代码将该文件上传到存储桶中,但出现错误

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());

错误

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

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)