从localhost上传到Amazon S3

时间:2016-08-12 10:56:27

标签: java amazon-web-services amazon-s3 tomcat7

我正在尝试使用本地计算机上的Tomcat 7将文件上传到Amazon S3。我在尝试创建AmazonS3Client时遇到错误。相同的代码在桌面应用程序中运行良好。

String existingBucketName  = "namebucket"; 
String keyName             = "test.txt";
String filePath            = "C://test.txt";

AWSCredentials credentials = new BasicAWSCredentials("****","*********");
AmazonS3 s3Client = new AmazonS3Client(credentials);       
File file = new File(filePath);
s3Client.putObject(new PutObjectRequest(existingBucketName, keyName, file));

0 个答案:

没有答案