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 Details

  • 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 name
      range - 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:
      ResponseEntity with Status Code and empty ETag.
      Throws:
      XMLStreamException
      JAXBException
    • 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:
      ResponseEntity with 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 name
      body - 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 name
      body - 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 name
      body - 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:
      ResponseEntity with 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 bucket
      copySource - path to source object
      Returns:
      CopyObjectResult