Sample code for 30+ languages & platforms
Java Requires Chilkat v11.0.0+

Generate S3 Signed URL

See more Amazon S3 Examples

Demonstrates how to generate a pre-signed S3 URL.

Chilkat Java Downloads

Chilkat2 Java
import com.chilkatsoft.chilkat2.ChilkatException;
import com.chilkatsoft.chilkat2.Http;

public class ChilkatExample {

    public static void main(String[] args) {
        // This example assumes the Chilkat API to have been previously unlocked.
        // See Global Unlock Sample for sample code.

        Http http = new Http();

        // Insert your access key here:
        http.setAwsAccessKey("AWS_ACCESS_KEY");

        // Insert your secret key here:
        http.setAwsSecretKey("AWS_SECRET_KEY");

        http.setAwsRegion("us-west-2");
        http.setAwsEndpoint("s3-us-west-2.amazonaws.com");

        String bucketName = "chilkattest";
        String path = "starfish.jpg";

        String signedUrl;
        try {
            signedUrl = http.s3GenPresignedUrl("GET", true, bucketName, path, 3600, "s3");
        } catch (ChilkatException e) {
            System.out.println(e.getLastErrorText());
            return;
        }

        System.out.println(signedUrl);
    }
}