其实我一直在尝试使用java代码从amazon s3 bucket文件夹下载特定文件,但我没有找到任何人的值得回答。
package com.simon.amazonbucket;
import java.io.FileOutputStream;
import org.apache.tomcat.util.http.fileupload.IOUtils;
import com.amazonaws.auth.ClasspathPropertiesFileCredentialsProvider;
import com.amazonaws.services.s3.AmazonS3;
import com.amazonaws.services.s3.AmazonS3Client;
import com.amazonaws.services.s3.model.GetObjectRequest;
import com.amazonaws.services.s3.model.S3Object;
import com.amazonaws.services.s3.model.S3ObjectInputStream;
public class DownloadingImage {
public static void main(String[] args) {
AmazonS3 s3 = new AmazonS3Client(
new ClasspathPropertiesFileCredentialsProvider());
try {
/* GetObjectRequest obj = new GetObjectRequest("simon-aluvala/simonFolder",
"/" + "");
S3Object gobj = s3.getObject(obj);
String name = gobj.getKey();
S3ObjectInputStream in = gobj.getObjectContent();
IOUtils.copy(in, new FileOutputStream(
"C:/Users/ycs/Desktop/test.doc"));
System.out.println("downloaded successfully...............");*/
} catch (Exception e) {
e.printStackTrace();
}
}
}
答案 0 :(得分:0)
如何使用AWS SDK for Java获取对象:
您可以在此处找到示例:http://docs.aws.amazon.com/AmazonS3/latest/dev/RetrievingObjectUsingJava.html
[Disclousre:Bucket Explorer]