我一直在使用以下 Java 方法在 GCS 中设置存储桶通知。
private void setBucketNotification(String bucketName, String topicId) {
List<String> eventType = new ArrayList<>();
eventType.add("OBJECT_FINALIZE");
try {
Notification notification = new Notification();
notification.setTopic(topicId);
notification.setEventTypes(eventType);
notification.setPayloadFormat("JSON_API_V1");
final GoogleCredential googleCredential = GoogleCredential
.fromStream(Objects.requireNonNull(classloader.getResourceAsStream("Key.json")))
.createScoped(Collections.singletonList(StorageScopes.DEVSTORAGE_FULL_CONTROL));
final com.google.api.services.storage.Storage myStorage = new com.google.api.services.storage.Storage.Builder(
new NetHttpTransport(), new JacksonFactory(), googleCredential).build();
Notification v = myStorage.notifications().insert(bucketName, notification).execute();
} catch (IOException e) {
log.error("Caught an IOException {}",e);
}
}
到目前为止,它运行良好,但最近,我收到了有关班级弃用的投诉GoogleCredential,并尝试做一些研究,希望找到可能的替代品,但找不到任何东西。谁能帮我指出正确的方向?
大话西游666
慕运维8079593
繁华开满天机
拉莫斯之舞
相关分类