gpt4 book ai didi

amazon-s3 - AmazonS3Client 中的 putObject 是否阻塞?

转载 作者:行者123 更新时间:2023-12-02 03:01:45 25 4
gpt4 key购买 nike

你知道方法吗 -

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

http://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/services/s3/transfer/TransferManager.html

关于amazon-s3 - AmazonS3Client 中的 putObject 是否阻塞?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40865805/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com