你知道方法 -
吗?public PutObjectResult putObject(PutObjectRequest putObjectRequest)
在AmazonS3Client
阻止?
答案 0 :(得分:4)
是的,它是阻止的,它会返回一个结果。如果您想进行更复杂的上传,请查看:
DefaultAWSCredentialsProviderChain credentialProviderChain = new DefaultAWSCredentialsProviderChain();
TransferManager tx = new TransferManager(
credentialProviderChain.getCredentials());
Upload myUpload = tx.upload(myBucket, myFile.getName(), myFile);
// You can poll your transfer's status to check its progress
if (myUpload.isDone() == false) {
System.out.println("Transfer: " + myUpload.getDescription());
System.out.println(" - State: " + myUpload.getState());
System.out.println(" - Progress: "
+ myUpload.getProgress().getBytesTransferred());
}
// Transfers also allow you to set a <code>ProgressListener</code> to receive
// asynchronous notifications about your transfer's progress.
myUpload.addProgressListener(myProgressListener);
// Or you can block the current thread and wait for your transfer to
// to complete. If the transfer fails, this method will throw an
// AmazonClientException or AmazonServiceException detailing the reason.
myUpload.waitForCompletion();
// After the upload is complete, call shutdownNow to release the resources.
tx.shutdownNow();