Package com.adobe.testing.s3mock
Class ObjectController
java.lang.Object
com.adobe.testing.s3mock.ObjectController
@CrossOrigin(origins="*",
exposedHeaders="*")
@RequestMapping("${com.adobe.testing.s3mock.contextPath:}")
public class ObjectController
extends Object
Handles requests related to objects.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.http.ResponseEntity<CopyObjectResult>copyObject(String bucketName, ObjectKey key, CopySource copySource, AwsHttpHeaders.MetadataDirective metadataDirective, List<String> match, List<String> noneMatch, org.springframework.http.HttpHeaders httpHeaders) Copies an object to another bucket.org.springframework.http.ResponseEntity<Void>deleteObject(String bucketName, ObjectKey key) The DELETE operation removes an object.org.springframework.http.ResponseEntity<DeleteResult>deleteObjects(String bucketName, Delete body) This operation removes multiple objects.org.springframework.http.ResponseEntity<LegalHold>getLegalHold(String bucketName, ObjectKey key) Returns the legal hold for an object.org.springframework.http.ResponseEntity<org.springframework.web.servlet.mvc.method.annotation.StreamingResponseBody>getObject(String bucketName, ObjectKey key, org.springframework.http.HttpRange range, List<String> match, List<String> noneMatch, Map<String, String> queryParams) Returns the File identified by bucketName and fileName.org.springframework.http.ResponseEntity<String>getObjectAcl(String bucketName, ObjectKey key) Gets ACL of an object.org.springframework.http.ResponseEntity<GetObjectAttributesOutput>getObjectAttributes(String bucketName, ObjectKey key, List<String> match, List<String> noneMatch, List<String> objectAttributes) Returns the attributes for an object.org.springframework.http.ResponseEntity<Retention>getObjectRetention(String bucketName, ObjectKey key) Returns the retention for an object.org.springframework.http.ResponseEntity<Tagging>getObjectTagging(String bucketName, ObjectKey key) Returns the tags identified by bucketName and fileName.org.springframework.http.ResponseEntity<Void>Retrieves metadata from an object without returning the object itself.org.springframework.http.ResponseEntity<Void>putLegalHold(String bucketName, ObjectKey key, LegalHold body) Sets legal hold for an object.org.springframework.http.ResponseEntity<Void>putObject(String bucketName, ObjectKey key, List<Tag> tags, String contentType, String contentMd5, String sha256Header, org.springframework.http.HttpHeaders httpHeaders, InputStream inputStream) Adds an object to a bucket.org.springframework.http.ResponseEntity<Void>putObjectAcl(String bucketName, ObjectKey key, String body) Adds an ACL to an object.org.springframework.http.ResponseEntity<Void>putObjectRetention(String bucketName, ObjectKey key, Retention body) Sets retention for an object.org.springframework.http.ResponseEntity<Void>putObjectTagging(String bucketName, ObjectKey key, Tagging body) Sets tags for a file identified by bucketName and fileName.
-
Constructor Details
-
ObjectController
-
-
Method Details
-
deleteObjects
@RequestMapping(value="/{bucketName:.+}", params="delete", method=POST, consumes="application/xml", produces="application/xml") public org.springframework.http.ResponseEntity<DeleteResult> deleteObjects(@PathVariable String bucketName, @RequestBody Delete body) This operation removes multiple objects. API Reference- Parameters:
bucketName- name of bucket containing the object.body- The delete request.- Returns:
- The
DeleteResult
-
headObject
@RequestMapping(value="/{bucketName:.+}/{*key}", method=HEAD) public org.springframework.http.ResponseEntity<Void> headObject(@PathVariable String bucketName, @PathVariable ObjectKey key, @RequestHeader(value="If-Match",required=false) List<String> match, @RequestHeader(value="If-None-Match",required=false) List<String> noneMatch) Retrieves metadata from an object without returning the object itself. API Reference- Parameters:
bucketName- name of the bucket to look in- Returns:
- 200 with object metadata headers, 404 if not found.
-
deleteObject
@RequestMapping(value="/{bucketName:.+}/{*key}", params="!lifecycle", method=DELETE) public org.springframework.http.ResponseEntity<Void> deleteObject(@PathVariable String bucketName, @PathVariable ObjectKey key) The DELETE operation removes an object. API Reference- Parameters:
bucketName- name of bucket containing the object.- Returns:
- ResponseEntity with Status Code 204 if object was successfully deleted.
-
getObject
@RequestMapping(value="/{bucketName:.+}/{*key}", params={"!uploads","!uploadId","!tagging","!legal-hold","!retention","!acl","!attributes"}, method=GET) public org.springframework.http.ResponseEntity<org.springframework.web.servlet.mvc.method.annotation.StreamingResponseBody> getObject(@PathVariable String bucketName, @PathVariable ObjectKey key, @RequestHeader(value="Range",required=false) org.springframework.http.HttpRange range, @RequestHeader(value="If-Match",required=false) List<String> match, @RequestHeader(value="If-None-Match",required=false) List<String> noneMatch, @RequestParam Map<String, String> queryParams) Returns the File identified by bucketName and fileName. API Reference- Parameters:
bucketName- The Bucket's namerange- byte range
-
putObjectAcl
@RequestMapping(value="/{bucketName:.+}/{*key}", params="acl", method=PUT, consumes="application/xml") public org.springframework.http.ResponseEntity<Void> putObjectAcl(@PathVariable String bucketName, @PathVariable ObjectKey key, @RequestBody String body) throws XMLStreamException, JAXBException Adds an ACL to an object. This method accepts a String instead of the POJO. We need to use JAX-B annotations instead of Jackson annotations because AWS decided to use xsi:type annotations in the XML representation, which are not supported by Jackson. It doesn't seem to be possible to use bot JAX-B and Jackson for (de-)serialization in parallel. :-( API Reference- Parameters:
bucketName- the Bucket in which to store the file in.- Returns:
ResponseEntitywith Status Code and empty ETag.- Throws:
XMLStreamExceptionJAXBException
-
getObjectAcl
@RequestMapping(value="/{bucketName:.+}/{*key}", params="acl", method=GET, produces="application/xml") public org.springframework.http.ResponseEntity<String> getObjectAcl(@PathVariable String bucketName, @PathVariable ObjectKey key) throws JAXBException Gets ACL of an object. This method returns a String instead of the POJO. We need to use JAX-B annotations instead of Jackson annotations because AWS decided to use xsi:type annotations in the XML representation, which are not supported by Jackson. It doesn't seem to be possible to use bot JAX-B and Jackson for (de-)serialization in parallel. :-( API Reference- Parameters:
bucketName- the Bucket in which to store the file in.- Returns:
ResponseEntitywith Status Code and empty ETag.- Throws:
JAXBException
-
getObjectTagging
@RequestMapping(value="/{bucketName:.+}/{*key}", params="tagging", method=GET, produces="application/xml") public org.springframework.http.ResponseEntity<Tagging> getObjectTagging(@PathVariable String bucketName, @PathVariable ObjectKey key) Returns the tags identified by bucketName and fileName. API Reference- Parameters:
bucketName- The Bucket's name
-
putObjectTagging
@RequestMapping(value="/{bucketName:.+}/{*key}", params="tagging", method=PUT, consumes="application/xml") public org.springframework.http.ResponseEntity<Void> putObjectTagging(@PathVariable String bucketName, @PathVariable ObjectKey key, @RequestBody Tagging body) Sets tags for a file identified by bucketName and fileName. API Reference- Parameters:
bucketName- The Bucket's namebody- Tagging object
-
getLegalHold
@RequestMapping(value="/{bucketName:.+}/{*key}", params="legal-hold", method=GET, produces="application/xml") public org.springframework.http.ResponseEntity<LegalHold> getLegalHold(@PathVariable String bucketName, @PathVariable ObjectKey key) Returns the legal hold for an object. API Reference API Reference- Parameters:
bucketName- The Bucket's name
-
putLegalHold
@RequestMapping(value="/{bucketName:.+}/{*key}", params="legal-hold", method=PUT, consumes="application/xml") public org.springframework.http.ResponseEntity<Void> putLegalHold(@PathVariable String bucketName, @PathVariable ObjectKey key, @RequestBody LegalHold body) Sets legal hold for an object. API Reference- Parameters:
bucketName- The Bucket's namebody- legal hold
-
getObjectRetention
@RequestMapping(value="/{bucketName:.+}/{*key}", params="retention", method=GET, produces="application/xml") public org.springframework.http.ResponseEntity<Retention> getObjectRetention(@PathVariable String bucketName, @PathVariable ObjectKey key) Returns the retention for an object. API Reference API Reference- Parameters:
bucketName- The Bucket's name
-
putObjectRetention
@RequestMapping(value="/{bucketName:.+}/{*key}", params="retention", method=PUT, consumes="application/xml") public org.springframework.http.ResponseEntity<Void> putObjectRetention(@PathVariable String bucketName, @PathVariable ObjectKey key, @RequestBody Retention body) Sets retention for an object. API Reference- Parameters:
bucketName- The Bucket's namebody- retention
-
getObjectAttributes
@RequestMapping(value="/{bucketName:[a-z0-9.-]+}/{*key}", params="attributes", method=GET, produces="application/xml") public org.springframework.http.ResponseEntity<GetObjectAttributesOutput> getObjectAttributes(@PathVariable String bucketName, @PathVariable ObjectKey key, @RequestHeader(value="If-Match",required=false) List<String> match, @RequestHeader(value="If-None-Match",required=false) List<String> noneMatch, @RequestHeader("x-amz-object-attributes") List<String> objectAttributes) Returns the attributes for an object. API Reference- Parameters:
bucketName- The Bucket's name
-
putObject
@RequestMapping(params={"!uploadId","!tagging","!legal-hold","!retention","!acl"}, headers="!x-amz-copy-source", value="/{bucketName:.+}/{*key}", method=PUT) public org.springframework.http.ResponseEntity<Void> putObject(@PathVariable String bucketName, @PathVariable ObjectKey key, @RequestHeader(name="x-amz-tagging",required=false) List<Tag> tags, @RequestHeader(value="Content-Type",required=false) String contentType, @RequestHeader(value="Content-MD5",required=false) String contentMd5, @RequestHeader(value="x-amz-content-sha256",required=false) String sha256Header, @RequestHeader org.springframework.http.HttpHeaders httpHeaders, InputStream inputStream) Adds an object to a bucket. API Reference- Parameters:
bucketName- the Bucket in which to store the file in.- Returns:
ResponseEntitywith Status Code and empty ETag.
-
copyObject
@RequestMapping(value="/{bucketName:.+}/{*key}", headers="x-amz-copy-source", params={"!uploadId","!tagging","!legal-hold","!retention","!acl"}, method=PUT, produces="application/xml") public org.springframework.http.ResponseEntity<CopyObjectResult> copyObject(@PathVariable String bucketName, @PathVariable ObjectKey key, @RequestHeader("x-amz-copy-source") CopySource copySource, @RequestHeader(value="x-amz-metadata-directive",defaultValue="COPY") AwsHttpHeaders.MetadataDirective metadataDirective, @RequestHeader(value="x-amz-copy-source-if-match",required=false) List<String> match, @RequestHeader(value="x-amz-copy-source-if-none-match",required=false) List<String> noneMatch, @RequestHeader org.springframework.http.HttpHeaders httpHeaders) Copies an object to another bucket. API Reference- Parameters:
bucketName- name of the destination bucketcopySource- path to source object- Returns:
CopyObjectResult
-