Class S3Object

    • Constructor Detail

      • S3Object

        public S3Object​(S3Bucket bucket,
                        File file)
                 throws NoSuchAlgorithmException,
                        IOException
        Create an object representing a file. The object is initialised with the file's name as its key, the file's content as its data, a content type based on the file's extension (see Mimetypes), and a content length matching the file's size. The file's MD5 hash value is also calculated and provided to S3, so the service can verify that no data are corrupted in transit.

        NOTE: The automatic calculation of a file's MD5 hash digest as performed by this constructor could take some time for large files, or for many small ones.

        Parameters:
        bucket - the bucket the object belongs to, or will be placed in.
        file - the file the object will represent. This file must exist and be readable.
        Throws:
        IOException - when an i/o error occurred reading the file
        NoSuchAlgorithmException - when this JRE doesn't support the MD5 hash algorithm
      • S3Object

        public S3Object​(File file)
                 throws NoSuchAlgorithmException,
                        IOException
        Create an object representing a file. The object is initialised with the file's name as its key, the file's content as its data, a content type based on the file's extension (see Mimetypes), and a content length matching the file's size. The file's MD5 hash value is also calculated and provided to S3, so the service can verify that no data are corrupted in transit.

        NOTE: The automatic calculation of a file's MD5 hash digest as performed by this constructor could take some time for large files, or for many small ones.

        Parameters:
        file - the file the object will represent. This file must exist and be readable.
        Throws:
        IOException - when an i/o error occurred reading the file
        NoSuchAlgorithmException - when this JRE doesn't support the MD5 hash algorithm
      • S3Object

        public S3Object​(S3Bucket bucket,
                        String key,
                        String dataString)
                 throws NoSuchAlgorithmException,
                        IOException
        Create an object representing text data. The object is initialized with the given key, the given string as its data content (encoded as UTF-8), a content type of text/plain; charset=utf-8, and a content length matching the string's length. The given string's MD5 hash value is also calculated and provided to S3, so the service can verify that no data are corrupted in transit.

        NOTE: The automatic calculation of the MD5 hash digest as performed by this constructor could take some time for large strings, or for many small ones.

        Parameters:
        bucket - the bucket the object belongs to, or will be placed in.
        key - the key name for the object.
        dataString - the text data the object will contain. Text data will be encoded as UTF-8. This string cannot be null.
        Throws:
        IOException
        NoSuchAlgorithmException - when this JRE doesn't support the MD5 hash algorithm
      • S3Object

        public S3Object​(String key,
                        String dataString)
                 throws NoSuchAlgorithmException,
                        IOException
        Create an object representing text data. The object is initialized with the given key, the given string as its data content (encoded as UTF-8), a content type of text/plain; charset=utf-8, and a content length matching the string's length. The given string's MD5 hash value is also calculated and provided to S3, so the service can verify that no data are corrupted in transit.

        NOTE: The automatic calculation of the MD5 hash digest as performed by this constructor could take some time for large strings, or for many small ones.

        Parameters:
        key - the key name for the object.
        dataString - the text data the object will contain. Text data will be encoded as UTF-8. This string cannot be null.
        Throws:
        IOException
        NoSuchAlgorithmException - when this JRE doesn't support the MD5 hash algorithm
      • S3Object

        public S3Object​(String key,
                        byte[] data)
                 throws NoSuchAlgorithmException,
                        IOException
        Create an object representing binary data. The object is initialized with the given key, the bytes as its data content, a content type of application/octet-stream, and a content length matching the byte array's length. The MD5 hash value of the byte data is also calculated and provided to the target service, so the service can verify that no data are corrupted in transit.
        Parameters:
        key - the key name for the object.
        data - the byte data the object will contain, cannot be null.
        Throws:
        IOException
        NoSuchAlgorithmException - when this JRE doesn't support the MD5 hash algorithm
      • S3Object

        public S3Object​(String key)
        Create an object without any associated data, and no associated bucket.
        Parameters:
        key - the key name for the object.
      • S3Object

        public S3Object​(S3Bucket bucket,
                        String key)
        Create an object without any associated data.
        Parameters:
        bucket - the bucket the object belongs to, or will be placed in.
        key - the key name for the object.
      • S3Object

        public S3Object()
        Create an object without any associated information whatsoever.