2
你知道的方法 -PutObject是否在AmazonS3Client中阻塞?
public PutObjectResult putObject(PutObjectRequest putObjectRequest)
在AmazonS3Client
拦截?
你知道的方法 -PutObject是否在AmazonS3Client中阻塞?
public PutObjectResult putObject(PutObjectRequest putObjectRequest)
在AmazonS3Client
拦截?
是的,它是阻塞的,它返回一个结果。如果你想要做更复杂的上传,看看这个:
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();
它返回一个结果并不能使它非阻塞的事实。数据实际写入后确实返回结果的任何其他指标? –
如果它返回一个表明它已完成的结果,则它必须等待,直到它知道何时完成为止......从putObject方法的文档中,“Amazon S3从不存储部分对象;如果在此调用期间没有例外抛出,整个对象被存储。“所以这个呼叫阻塞,直到上传完成或错误 – hellomichibye