Search in sources :

Example 1 with MultipartUtils

use of org.jets3t.service.utils.MultipartUtils in project hadoop by apache.

the class Jets3tNativeFileSystemStore method storeLargeFile.

public void storeLargeFile(String key, File file, byte[] md5Hash) throws IOException {
    S3Object object = new S3Object(key);
    object.setDataInputFile(file);
    object.setContentType("binary/octet-stream");
    object.setContentLength(file.length());
    object.setServerSideEncryptionAlgorithm(serverSideEncryptionAlgorithm);
    if (md5Hash != null) {
        object.setMd5Hash(md5Hash);
    }
    List<StorageObject> objectsToUploadAsMultipart = new ArrayList<StorageObject>();
    objectsToUploadAsMultipart.add(object);
    MultipartUtils mpUtils = new MultipartUtils(multipartBlockSize);
    try {
        mpUtils.uploadObjects(bucket.getName(), s3Service, objectsToUploadAsMultipart, null);
    } catch (Exception e) {
        handleException(e, key);
    }
}
Also used : StorageObject(org.jets3t.service.model.StorageObject) ArrayList(java.util.ArrayList) S3Object(org.jets3t.service.model.S3Object) MultipartUtils(org.jets3t.service.utils.MultipartUtils) ServiceException(org.jets3t.service.ServiceException) HttpException(org.jets3t.service.impl.rest.HttpException) S3ServiceException(org.jets3t.service.S3ServiceException) IOException(java.io.IOException) EOFException(java.io.EOFException) FileNotFoundException(java.io.FileNotFoundException) AccessControlException(org.apache.hadoop.security.AccessControlException)

Aggregations

EOFException (java.io.EOFException)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 AccessControlException (org.apache.hadoop.security.AccessControlException)1 S3ServiceException (org.jets3t.service.S3ServiceException)1 ServiceException (org.jets3t.service.ServiceException)1 HttpException (org.jets3t.service.impl.rest.HttpException)1 S3Object (org.jets3t.service.model.S3Object)1 StorageObject (org.jets3t.service.model.StorageObject)1 MultipartUtils (org.jets3t.service.utils.MultipartUtils)1