Load document from Amazon S3 Storage

Following example demonstrates how to process with documents from Amazon S3 Storage.

public static void run()
    String key = "sample.docx";
    try {
        InputStream stream = downloadFile(key);
        Signature signature = new Signature(stream);
        QrCodeSignOptions options = new QrCodeSignOptions("JohnSmith");
        // sign document to file
        signature.sign("signedSample.docx", options);
        System.out.print("\nSource document signed successfully.\n" );
    }catch(Exception e){
        throw new GroupDocsSignatureException(e.getMessage());
public static InputStream downloadFile(String key)
    AWSCredentials credentials = new BasicAWSCredentials(
            "<AWS accesskey>",
            "<AWS secretkey>"
    AmazonS3 s3client = AmazonS3ClientBuilder.standard()
                                             .withCredentials(new AWSStaticCredentialsProvider(credentials))
    String bucketName = "my-bucket";
    S3Object s3object = s3client.getObject(bucketName, key);
    S3ObjectInputStream inputStream = s3object.getObjectContent();
    return inputStream;

More resources

GitHub Examples 

You may easily run the code above and see the feature in action in our GitHub examples:

Free Online App 

Along with full-featured .NET library we provide simple, but powerful free Apps.
You are welcome to eSign PDF, Word, Excel, PowerPoint documents with free to use online GroupDocs Signature App.