No, you canβt get the URL in one action, but two :)
First of all, you may need to make the file public before downloading, because it makes no sense to get a URL that no one can access. You can do this by setting the ACL as suggested by Michael Astreiko. You can get the resource URL by calling getResourceUrl or getUrl .
AmazonS3Client s3Client = (AmazonS3Client)AmazonS3ClientBuilder.defaultClient(); s3Client.putObject(new PutObjectRequest("your-bucket", "some-path/some-key.jpg", new File("somePath/someKey.jpg")).withCannedAcl(CannedAccessControlList.PublicRead)) s3Client.getResourceUrl("your-bucket", "some-path/some-key.jpg");
Note getResourceUrl difference between getResourceUrl and getUrl is that getResourceUrl will return zero when an exception occurs.
Note 2: the getUrl method getUrl not defined in the AmazonS3 interface. You must cast the object to AmazonS3Client if you use the standard linker.
hussachai Jun 26 '15 at 17:58 2015-06-26 17:58
source share