The following code snippet shows how to convert a document from Amazon S3 Storage:
Note
This example uses the AWS SDK for Java v1. Add the com.amazonaws:aws-java-sdk-s3 Maven dependency (for example, version 1.12.780) to your project.
importcom.amazonaws.auth.AWSCredentials;importcom.amazonaws.auth.AWSStaticCredentialsProvider;importcom.amazonaws.auth.BasicAWSCredentials;importcom.amazonaws.regions.Regions;importcom.amazonaws.services.s3.AmazonS3;importcom.amazonaws.services.s3.AmazonS3ClientBuilder;importcom.amazonaws.services.s3.model.S3Object;importcom.amazonaws.services.s3.model.S3ObjectInputStream;importcom.groupdocs.conversion.Converter;importjava.io.InputStream;importcom.groupdocs.conversion.options.convert.PdfConvertOptions;/**
* This example demonstrates how to download document from Amazon S3 storage and convert document.
*/publicclassLoadDocumentFromAmazonS3{publicstaticvoidrun(){Stringkey="sample.docx";StringconvertedFile="C:\\output\\converted.pdf";Converterconverter=newConverter(()->downloadFile(key));PdfConvertOptionsoptions=newPdfConvertOptions();converter.convert(convertedFile,options);System.out.print("\nSource document converted successfully.\nCheck output in "+convertedFile);}publicstaticInputStreamdownloadFile(Stringkey){AWSCredentialscredentials=newBasicAWSCredentials("<AWS accesskey>","<AWS secretkey>");AmazonS3s3client=AmazonS3ClientBuilder.standard().withCredentials(newAWSStaticCredentialsProvider(credentials)).withRegion(Regions.US_EAST_2).build();StringbucketName="my-bucket";S3Objects3object=s3client.getObject(bucketName,key);S3ObjectInputStreaminputStream=s3object.getObjectContent();returninputStream;}}
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.
Ask AI
Ask anything about this page — the answer is based on its content.
Searching the docs and writing an answer…
Something went wrong while getting an answer. Please try again in a moment.