ceph rgw java_ceph rgw s3 java sdk 上传大文件分批的方法

The following Java code example uploads a file to an Amazon S3 bucket. For instructions on how to create and test a working sample, see Testing the Java Code Examples.

import java.io.File;

import com.amazonaws.AmazonClientException;

import com.amazonaws.auth.profile.ProfileCredentialsProvider;

import com.amazonaws.services.s3.transfer.TransferManager;

import com.amazonaws.services.s3.transfer.Upload;

public class UploadObjectMultipartUploadUsingHighLevelAPI {

public static void main(String[] args) throws Exception {

String existingBucketName = "*** Provide existing bucket name ***";

String keyName = "*** Provide object key ***";

String filePath = "*** Path to and name of the file to upload ***";

TransferManager tm = new TransferManager(new ProfileCredentialsProvider());

System.out.println("Hello");

// TransferManager processes all transfers asynchronously,

// so this call will return immediately.

Upload upload = tm.upload(

existingBucketName, keyName, new File(filePath));

System.out.println("Hello2");

try {

// Or you can block and wait for the upload to finish

upload.waitForCompletion();

System.out.println("Upload complete.");

} catch (AmazonClientException amazonClientException) {

System.out.println("Unable to upload file, upload was aborted.");

amazonClientException.printStackTrace();

}

}

}

http://docs.aws.amazon.com/AmazonS3/latest/dev/HLuploadFileJava.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值