0
は、応答対象外のエラーをキャプチャする方法Storage.Objects.Insert要求の失敗/エラーをキャプチャする方法は?ここ
public static void uploadFile(String name, String contentType, File file, String bucketName)
throws IOException, GeneralSecurityException {
InputStreamContent contentStream = new InputStreamContent(contentType, new FileInputStream(file));
// Setting the length improves upload performance
contentStream.setLength(file.length());
StorageObject objectMetadata = new StorageObject()
// Set the destination object name
.setName(name)
// Set the access control list to publicly read-only
.setAcl(Arrays.asList(new ObjectAccessControl().setEntity("allUsers").setRole("READER")));
// Do the insert
Storage client = StorageFactory.getService();
Storage.Objects.Insert insertRequest = client.objects().insert(bucketName, objectMetadata, contentStream);
StorageObject response =insertRequest.execute();
System.out.println("Storage insert response: "+response.toPrettyString());
}
、Googleのクラウドストレージにファイルをアップロードする私のコードですか?