public void storeFile(String key, File file, byte[] md5Hash) throws IOException { BufferedInputStream in = null; try { in = new BufferedInputStream(new FileInputStream(file)); S3Object object = new S3Object(key); object.setDataInputStream(in); object.setContentType("binary/octet-stream"); object.setContentLength(file.length()); if (md5Hash != null) { object.setMd5Hash(md5Hash); } s3Service.putObject(bucket, object); } catch (S3ServiceException e) { if (e.getCause() instanceof IOException) { throw (IOException) e.getCause(); } throw new S3Exception(e); } finally { if (in != null) { try { in.close(); } catch (IOException e) { // ignore } } } }
public void storeFile(String key, File file, byte[] md5Hash) throws IOException { BufferedInputStream in = null; try { in = new BufferedInputStream(new FileInputStream(file)); S3Object object = new S3Object(key); object.setDataInputStream(in); object.setContentType("binary/octet-stream"); object.setContentLength(file.length()); if (md5Hash != null) { object.setMd5Hash(md5Hash); } s3Service.putObject(bucket, object); } catch (S3ServiceException e) { if (e.getCause() instanceof IOException) { throw (IOException) e.getCause(); } throw new S3Exception(e); } finally { if (in != null) { try { in.close(); } catch (IOException e) { // ignore } } } }
@Override public void storeFile(String key, File file, byte[] md5Hash) throws IOException { if (multipartEnabled && file.length() >= multipartBlockSize) { storeLargeFile(key, file, md5Hash); return; } BufferedInputStream in = null; try { in = new BufferedInputStream(new FileInputStream(file)); S3Object object = new S3Object(key); object.setDataInputStream(in); object.setContentType("binary/octet-stream"); object.setContentLength(file.length()); object.setServerSideEncryptionAlgorithm(serverSideEncryptionAlgorithm); if (md5Hash != null) { object.setMd5Hash(md5Hash); } s3Service.putObject(bucket, object); } catch (ServiceException e) { handleException(e, key); } finally { IOUtils.closeStream(in); } }
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); } }
object.setMd5Hash(ServiceUtils.computeMD5Hash(segFIS)); segFIS.reset();
object.setMd5Hash(ServiceUtils.computeMD5Hash(segFIS)); segFIS.reset();
s3Object.setMd5Hash(md5HashOfUploadFile);
s3Object.setMd5Hash(md5HashOfUploadFile);
switch(checksum.algorithm) { case md5: object.setMd5Hash(ServiceUtils.fromHex(checksum.hash)); break; case sha256:
object.setMd5Hash(fileHash); objectsForUpload[i] = object;
object.setMd5Hash(fileHash); objectsForUpload[i] = object;
stringObject.setMd5Hash(md5Hash);
stringObject.setMd5Hash(md5Hash);