public static byte[] hashSHA256(InputStream dataIS) throws IOException { return hashSHA256(dataIS, false); }
public static byte[] hashSHA256(InputStream dataIS) throws IOException { return hashSHA256(dataIS, false); }
/** * 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 {@link 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. * <p> * <b>NOTE:</b> 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. * * @param 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 * @throws NoSuchAlgorithmException when this JRE doesn't support the MD5 hash algorithm */ public S3Object(File file) throws NoSuchAlgorithmException, IOException { super(file); setSHA256Hash( ServiceUtils.hashSHA256(new FileInputStream(file))); }
/** * 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 {@link 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. * <p> * <b>NOTE:</b> 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. * * @param 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 * @throws NoSuchAlgorithmException when this JRE doesn't support the MD5 hash algorithm */ public S3Object(File file) throws NoSuchAlgorithmException, IOException { super(file); setSHA256Hash( ServiceUtils.hashSHA256(new FileInputStream(file))); }
/** * Create an object representing binary data. The object is initialized with the given * key, the bytes as its data content, a content type of * <code>application/octet-stream</code>, 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. * * @param key * the key name for the object. * @param data * the byte data the object will contain, cannot be null. * * @throws IOException * @throws NoSuchAlgorithmException when this JRE doesn't support the MD5 hash algorithm */ public S3Object(String key, byte[] data) throws NoSuchAlgorithmException, IOException { super(key, data); setSHA256Hash( ServiceUtils.hashSHA256(data)); }
/** * Create an object representing binary data. The object is initialized with the given * key, the bytes as its data content, a content type of * <code>application/octet-stream</code>, 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. * * @param key * the key name for the object. * @param data * the byte data the object will contain, cannot be null. * * @throws IOException * @throws NoSuchAlgorithmException when this JRE doesn't support the MD5 hash algorithm */ public S3Object(String key, byte[] data) throws NoSuchAlgorithmException, IOException { super(key, data); setSHA256Hash( ServiceUtils.hashSHA256(data)); }
/** * 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 {@link 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. * <p> * <b>NOTE:</b> 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. * * @param bucket * the bucket the object belongs to, or will be placed in. * @param 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 * @throws NoSuchAlgorithmException when this JRE doesn't support the MD5 hash algorithm */ public S3Object(S3Bucket bucket, File file) throws NoSuchAlgorithmException, IOException { super(file); if (bucket != null) { this.bucketName = bucket.getName(); } setSHA256Hash( ServiceUtils.hashSHA256(new FileInputStream(file))); }
/** * 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 {@link 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. * <p> * <b>NOTE:</b> 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. * * @param bucket * the bucket the object belongs to, or will be placed in. * @param 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 * @throws NoSuchAlgorithmException when this JRE doesn't support the MD5 hash algorithm */ public S3Object(S3Bucket bucket, File file) throws NoSuchAlgorithmException, IOException { super(file); if (bucket != null) { this.bucketName = bucket.getName(); } setSHA256Hash( ServiceUtils.hashSHA256(new FileInputStream(file))); }
/** * 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 * <code>text/plain; charset=utf-8</code>, 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. * <p> * <b>NOTE:</b> 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. * * @param key * the key name for the object. * @param dataString * the text data the object will contain. Text data will be encoded as UTF-8. * This string cannot be null. * * @throws IOException * @throws NoSuchAlgorithmException when this JRE doesn't support the MD5 hash algorithm */ public S3Object(String key, String dataString) throws NoSuchAlgorithmException, IOException { super(key, dataString); setSHA256Hash( ServiceUtils.hashSHA256(ServiceUtils.stringToBytes(dataString))); }
/** * 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 * <code>text/plain; charset=utf-8</code>, 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. * <p> * <b>NOTE:</b> 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. * * @param key * the key name for the object. * @param dataString * the text data the object will contain. Text data will be encoded as UTF-8. * This string cannot be null. * * @throws IOException * @throws NoSuchAlgorithmException when this JRE doesn't support the MD5 hash algorithm */ public S3Object(String key, String dataString) throws NoSuchAlgorithmException, IOException { super(key, dataString); setSHA256Hash( ServiceUtils.hashSHA256(ServiceUtils.stringToBytes(dataString))); }
ServiceUtils.hashSHA256( requestIS, true // resetInsteadOfClose - reset don't close
ServiceUtils.hashSHA256( requestIS, true // resetInsteadOfClose - reset don't close
ServiceUtils.hashSHA256(ServiceUtils.stringToBytes(dataString)));
ServiceUtils.hashSHA256(ServiceUtils.stringToBytes(dataString)));