use of com.amazonaws.services.s3.model in project aws-sdk-android by aws-amplify.
the class BucketConfigurationXmlFactory method convertToXmlByteArray.
/**
* Converts the specified
* {@link com.amazonaws.services.s3.model.analytics.AnalyticsConfiguration}
* object to an XML fragment that can be sent to Amazon S3.
*
* @param config The
* {@link com.amazonaws.services.s3.model.analytics.AnalyticsConfiguration}
*/
/*
* <AnalyticsConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
* <Id>XXX</Id> <Filter> <And> <Prefix>documents/</Prefix> <Tag>
* <Key>foo</Key> <Value>bar</Value> </Tag> </And> </Filter>
* <StorageClassAnalysis> <DataExport>
* <OutputSchemaVersion>1</OutputSchemaVersion> <Destination>
* <S3BucketDestination> <Format>CSV</Format>
* <BucketAccountId>123456789</BucketAccountId>
* <Bucket>destination-bucket</Bucket> <Prefix>destination-prefix</Prefix>
* </S3BucketDestination> </Destination> </DataExport>
* </StorageClassAnalysis> </AnalyticsConfiguration>
*/
public byte[] convertToXmlByteArray(AnalyticsConfiguration config) throws AmazonClientException {
final XmlWriter xml = new XmlWriter();
xml.start("AnalyticsConfiguration", "xmlns", Constants.XML_NAMESPACE);
addParameterIfNotNull(xml, "Id", config.getId());
writeAnalyticsFilter(xml, config.getFilter());
writeStorageClassAnalysis(xml, config.getStorageClassAnalysis());
xml.end();
return xml.getBytes();
}
use of com.amazonaws.services.s3.model in project aws-sdk-android by aws-amplify.
the class ServiceUtilsTest method skipMd5CheckPerRequestTest.
@Test
public void skipMd5CheckPerRequestTest() throws Throwable {
final S3ClientOptions clientOptions = S3ClientOptions.builder().skipContentMd5Check(true).build();
assertTrue(ServiceUtils.skipMd5CheckPerRequest(null, clientOptions));
System.setProperty("com.amazonaws.services.s3.disableGetObjectMD5Validation", "true");
assertTrue(ServiceUtils.skipMd5CheckPerRequest(null));
System.clearProperty("com.amazonaws.services.s3.disableGetObjectMD5Validation");
GetObjectRequest getObjectRequest = new GetObjectRequest("bucket", "key");
getObjectRequest.setRange(100);
assertTrue(ServiceUtils.skipMd5CheckPerRequest(getObjectRequest));
getObjectRequest = new GetObjectRequest("bucket", "key");
getObjectRequest.setSSECustomerKey(new SSECustomerKey("testKey"));
assertTrue(ServiceUtils.skipMd5CheckPerRequest(getObjectRequest));
getObjectRequest = new GetObjectRequest("bucket", "key");
assertFalse(ServiceUtils.skipMd5CheckPerRequest(getObjectRequest));
PutObjectRequest putObjectRequest = new PutObjectRequest("bucket", "key", File.createTempFile("test", "test2"));
final ObjectMetadata metadata = new ObjectMetadata();
metadata.setSSEAlgorithm(SSEAlgorithm.KMS.toString());
putObjectRequest.setMetadata(metadata);
assertTrue(ServiceUtils.skipMd5CheckPerRequest(putObjectRequest));
putObjectRequest = new PutObjectRequest("bucket", "key", File.createTempFile("test", "test2"));
putObjectRequest.setSSECustomerKey(new SSECustomerKey("testKey"));
assertTrue(ServiceUtils.skipMd5CheckPerRequest(putObjectRequest));
putObjectRequest = new PutObjectRequest("bucket", "key", File.createTempFile("test", "test2"));
assertFalse(ServiceUtils.skipMd5CheckPerRequest(putObjectRequest));
UploadPartRequest partRequest = new UploadPartRequest();
partRequest.setSSECustomerKey(new SSECustomerKey("testKey"));
assertTrue(ServiceUtils.skipMd5CheckPerRequest(partRequest));
partRequest = new UploadPartRequest();
assertFalse(ServiceUtils.skipMd5CheckPerRequest(partRequest));
}
use of com.amazonaws.services.s3.model in project aws-doc-sdk-examples by awsdocs.
the class DocumentText method main.
public static void main(String[] arg) throws Exception {
// The S3 bucket and document
String document = "";
String bucket = "";
AmazonS3 s3client = AmazonS3ClientBuilder.standard().withEndpointConfiguration(new EndpointConfiguration("https://s3.amazonaws.com", "us-east-1")).build();
// Get the document from S3
com.amazonaws.services.s3.model.S3Object s3object = s3client.getObject(bucket, document);
S3ObjectInputStream inputStream = s3object.getObjectContent();
BufferedImage image = ImageIO.read(inputStream);
// Call DetectDocumentText
EndpointConfiguration endpoint = new EndpointConfiguration("https://textract.us-east-1.amazonaws.com", "us-east-1");
AmazonTextract client = AmazonTextractClientBuilder.standard().withEndpointConfiguration(endpoint).build();
DetectDocumentTextRequest request = new DetectDocumentTextRequest().withDocument(new Document().withS3Object(new S3Object().withName(document).withBucket(bucket)));
DetectDocumentTextResult result = client.detectDocumentText(request);
// Create frame and panel.
JFrame frame = new JFrame("RotateImage");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
DocumentText panel = new DocumentText(result, image);
panel.setPreferredSize(new Dimension(image.getWidth(), image.getHeight()));
frame.setContentPane(panel);
frame.pack();
frame.setVisible(true);
}
use of com.amazonaws.services.s3.model in project aws-doc-sdk-examples by awsdocs.
the class AnalyzeDocument method main.
public static void main(String[] arg) throws Exception {
// The S3 bucket and document
String document = "";
String bucket = "";
AmazonS3 s3client = AmazonS3ClientBuilder.standard().withEndpointConfiguration(new EndpointConfiguration("https://s3.amazonaws.com", "us-east-1")).build();
// Get the document from S3
com.amazonaws.services.s3.model.S3Object s3object = s3client.getObject(bucket, document);
S3ObjectInputStream inputStream = s3object.getObjectContent();
BufferedImage image = ImageIO.read(inputStream);
// Call AnalyzeDocument
EndpointConfiguration endpoint = new EndpointConfiguration("https://textract.us-east-1.amazonaws.com", "us-east-1");
AmazonTextract client = AmazonTextractClientBuilder.standard().withEndpointConfiguration(endpoint).build();
AnalyzeDocumentRequest request = new AnalyzeDocumentRequest().withFeatureTypes("TABLES", "FORMS").withDocument(new Document().withS3Object(new S3Object().withName(document).withBucket(bucket)));
AnalyzeDocumentResult result = client.analyzeDocument(request);
// Create frame and panel.
JFrame frame = new JFrame("RotateImage");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
AnalyzeDocument panel = new AnalyzeDocument(result, image);
panel.setPreferredSize(new Dimension(image.getWidth(), image.getHeight()));
frame.setContentPane(panel);
frame.pack();
frame.setVisible(true);
}
use of com.amazonaws.services.s3.model in project xtext-core by eclipse.
the class Bug299395TestLanguageSemanticSequencer method sequence.
@Override
public void sequence(ISerializationContext context, EObject semanticObject) {
EPackage epackage = semanticObject.eClass().getEPackage();
ParserRule rule = context.getParserRule();
Action action = context.getAssignedAction();
Set<Parameter> parameters = context.getEnabledBooleanParameters();
if (epackage == Bug299395Package.eINSTANCE)
switch(semanticObject.eClass().getClassifierID()) {
case Bug299395Package.MODEL:
sequence_Model(context, (Model) semanticObject);
return;
case Bug299395Package.SUB_MODEL:
sequence_SubModel(context, (SubModel) semanticObject);
return;
}
if (errorAcceptor != null)
errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
}
Aggregations