简体   繁体   English

使用Java AWS S3客户端SDK和Cloudfront CDN端点从AWS S3下载映像

[英]Downloading an image from AWS S3 using java AWS S3 client sdk and cloudfront CDN end point

Currently, I am using the AmazonS3Client instance to download the S3 object using the "key" and "bucket name" as given below. 当前,我正在使用AmazonS3Client实例通过如下所示的“键”和“存储桶名称”下载S3对象。

object = s3Client.getObject(new GetObjectRequest(BucketDetails.getBucketDetails(), iconPath));
file  = new File(destinationPath);
reader = new BufferedInputStream( object.getObjectContent());        
writer = new BufferedOutputStream(new FileOutputStream(file));  
int read = -1;  
while ( ( read = reader.read() ) != -1 ) 
{     
      writer.write(read); 
}  
writer.flush(); 
writer.close();
reader.close(); 

This by default points to default S3 end point. 默认情况下,这指向默认的S3端点。

I have created a cloudfront distribution for my S3 access. 我已经为S3访问创建了一个Cloudfront发行版。

Can I set the endpoint of AmazonS3Client to cloud front distribution to improve the download performance? 是否可以将AmazonS3Client的端点设置为云前端分发以提高下载性能?

If you have Cloudfront distribution, and have made the files public, you shouldn't need any sort of AWS client library to access it. 如果您具有Cloudfront发行版本,并且已将文件公开,则不需要任何类型的AWS客户端库即可访问它。 You can just grab the file using your file retrieval mechanism of choice. 您可以使用选择的文件检索机制来获取文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM