Class ObjectController

java.lang.Object
com.adobe.testing.s3mock.ObjectController

@CrossOrigin(origins="*", exposedHeaders="*") @Controller @RequestMapping("${com.adobe.testing.s3mock.contextPath:}") public class ObjectController extends Object
Handles requests related to objects.
  • Constructor Details

  • Method Details

    • deleteObjects

      @PostMapping(value={"/{bucketName:.+}","/{bucketName:.+}/"}, params="delete", 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

      @DeleteMapping(value="/{bucketName:.+}/{*key}", params="!lifecycle") 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

      @GetMapping(value="/{bucketName:.+}/{*key}", params={"!uploads","!uploadId","!tagging","!legal-hold","!retention","!acl","!attributes"}) 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

      @PutMapping(value="/{bucketName:.+}/{*key}", params="acl", consumes="application/xml") public org.springframework.http.ResponseEntity<Void> putObjectAcl(@PathVariable String bucketName, @PathVariable ObjectKey key, @RequestBody String body) throws XMLStreamException, jakarta.xml.bind.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
      jakarta.xml.bind.JAXBException
    • getObjectAcl

      @GetMapping(value="/{bucketName:.+}/{*key}", params="acl", produces="application/xml") public org.springframework.http.ResponseEntity<String> getObjectAcl(@PathVariable String bucketName, @PathVariable ObjectKey key) throws jakarta.xml.bind.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:
      jakarta.xml.bind.JAXBException
    • getObjectTagging

      @GetMapping(value="/{bucketName:.+}/{*key}", params="tagging", produces={"application/xml","application/xml;charset=UTF-8"}) 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

      @PutMapping(value="/{bucketName:.+}/{*key}", params="tagging", 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

      @GetMapping(value="/{bucketName:.+}/{*key}", params="legal-hold", 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

      @PutMapping(value="/{bucketName:.+}/{*key}", params="legal-hold", 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

      @GetMapping(value="/{bucketName:.+}/{*key}", params="retention", 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

      @PutMapping(value="/{bucketName:.+}/{*key}", params="retention", 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

      @GetMapping(value="/{bucketName:[a-z0-9.-]+}/{*key}", params="attributes", 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

      @PutMapping(value="/{bucketName:.+}/{*key}", params={"!uploadId","!tagging","!legal-hold","!retention","!acl"}, headers="!x-amz-copy-source") 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

      @PutMapping(value="/{bucketName:.+}/{*key}", headers="x-amz-copy-source", params={"!uploadId","!tagging","!legal-hold","!retention","!acl"}, 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