Search in sources :

Example 1 with GetUrlRequest

use of software.amazon.awssdk.services.s3.model.GetUrlRequest in project aws-doc-sdk-examples by awsdocs.

the class GetObjectUrl method getURL.

// snippet-start:[s3.java2.getobjecturl.main]
public static void getURL(S3Client s3, String bucketName, String keyName) {
    try {
        GetUrlRequest request = GetUrlRequest.builder().bucket(bucketName).key(keyName).build();
        URL url = s3.utilities().getUrl(request);
        System.out.println("The URL for  " + keyName + " is " + url.toString());
    } catch (S3Exception e) {
        System.err.println(e.awsErrorDetails().errorMessage());
        System.exit(1);
    }
}
Also used : GetUrlRequest(software.amazon.awssdk.services.s3.model.GetUrlRequest) S3Exception(software.amazon.awssdk.services.s3.model.S3Exception) URL(java.net.URL)

Aggregations

URL (java.net.URL)1 GetUrlRequest (software.amazon.awssdk.services.s3.model.GetUrlRequest)1 S3Exception (software.amazon.awssdk.services.s3.model.S3Exception)1