Load from Amazon S3 Storage
Leave feedback
NoteInstall the AWS Java SDK for Amazon S3 module to use the Amazon S3 client.
The following code snippet shows how to load a document from Amazon S3 Storage:
import com.amazonaws.services.s3.AmazonS3Client;
import com.amazonaws.services.s3.model.GetObjectRequest;
import com.amazonaws.services.s3.model.S3Object;
import com.groupdocs.viewer.Viewer;
import com.groupdocs.viewer.options.HtmlViewOptions;
// ...
AmazonS3Client client = new AmazonS3Client();
GetObjectRequest request = new GetObjectRequest("my-bucket-name", "sample.docx");
S3Object response = client.getObject(request);
try (final InputStream inputStream = response.getObjectContent();
Viewer viewer = new Viewer(inputStream)) {
HtmlViewOptions viewOptions = HtmlViewOptions.forEmbeddedResources();
viewer.view(viewOptions);
}
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.