Load document from Amazon S3 Storage

Following example demonstrates how to render a document from Amazon S3 Storage.

    String key = "sample.docx";

    try (Viewer viewer = new Viewer(downloadFile(key))) {
        HtmlViewOptions viewOptions = HtmlViewOptions.forEmbeddedResources();
        
        viewer.view(viewOptions);
    }
    public InputStream downloadFile(String key) {
        AmazonS3Client client = new AmazonS3Client();
        String bucketName = "my-bucket";
        GetObjectRequest request = new GetObjectRequest();
        request.setKey(key);
        request.setBucketName(bucketName);
        GetObjectResponse response = client.getObject(request);
        return response.getResponseStream();
    }

© Aspose Pty Ltd 2001-2022. All Rights Reserved.