Actually i have been trying to download the specific file using it's name from amazon s3 bucket folder using java code but i didn't find the worth answer from anyone.
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();
}
}
}
How to Get an Object Using the AWS SDK for Java :
You can find example here : http://docs.aws.amazon.com/AmazonS3/latest/dev/RetrievingObjectUsingJava.html
[Disclousre : Bucket Explorer]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.