The following code snippet shows how to convert a document from Amazon S3 Storage:
packagecom.groupdocs.conversion.examples.advanced_usage.loading.loading_documents_from_different_sources;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;importcom.groupdocs.conversion.examples.Constants;importjava.io.File;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.