@Test public void close() throws Exception { mStream.close(); Mockito.verify(mFile).delete(); }
@Override public void close() throws IOException { if (mClosed) { return; } mLocalOutputStream.close(); String path = getUploadPath(); try { ObjectMetadata meta = new ObjectMetadata(); if (mSseEnabled) { meta.setSSEAlgorithm(ObjectMetadata.AES_256_SERVER_SIDE_ENCRYPTION); } if (mHash != null) { meta.setContentMD5(new String(Base64.encode(mHash.digest()))); } meta.setContentLength(mFile.length()); meta.setContentType(Mimetypes.MIMETYPE_OCTET_STREAM); PutObjectRequest putReq = new PutObjectRequest(mBucketName, path, mFile).withMetadata(meta); mManager.upload(putReq).waitForUploadResult(); } catch (Exception e) { LOG.error("Failed to upload {}: {}", path, e.toString()); throw new IOException(e); } finally { if (!mFile.delete()) { LOG.error("Failed to delete temporary file @ {}", mFile.getPath()); } mClosed = true; } }
S3AOutputStream extends OutputStream { @Override public void close() throws IOException { if (mClosed) { return; } mLocalOutputStream.close(); String path = getUploadPath(); try { ObjectMetadata meta = new ObjectMetadata(); if (mSseEnabled) { meta.setSSEAlgorithm(ObjectMetadata.AES_256_SERVER_SIDE_ENCRYPTION); } if (mHash != null) { meta.setContentMD5(new String(Base64.encode(mHash.digest()))); } meta.setContentLength(mFile.length()); meta.setContentType(Mimetypes.MIMETYPE_OCTET_STREAM); PutObjectRequest putReq = new PutObjectRequest(mBucketName, path, mFile).withMetadata(meta); mManager.upload(putReq).waitForUploadResult(); } catch (Exception e) { LOG.error("Failed to upload {}: {}", path, e.toString()); throw new IOException(e); } finally { if (!mFile.delete()) { LOG.error("Failed to delete temporary file @ {}", mFile.getPath()); } mClosed = true; } } }
S3AOutputStream extends OutputStream { @Override public void close() throws IOException { if (mClosed) { return; } mLocalOutputStream.close(); String path = getUploadPath(); try { ObjectMetadata meta = new ObjectMetadata(); if (mSseEnabled) { meta.setSSEAlgorithm(ObjectMetadata.AES_256_SERVER_SIDE_ENCRYPTION); } if (mHash != null) { meta.setContentMD5(new String(Base64.encode(mHash.digest()))); } meta.setContentLength(mFile.length()); meta.setContentType(Mimetypes.MIMETYPE_OCTET_STREAM); PutObjectRequest putReq = new PutObjectRequest(mBucketName, path, mFile).withMetadata(meta); mManager.upload(putReq).waitForUploadResult(); } catch (Exception e) { LOG.error("Failed to upload {}: {}", path, e.toString()); throw new IOException(e); } finally { if (!mFile.delete()) { LOG.error("Failed to delete temporary file @ {}", mFile.getPath()); } mClosed = true; } } S3AOutputStream(String bucketName, String key, TransferManager manager,
      List<String> tmpDirs, boolean sseEnabled); }
S3AOutputStream extends OutputStream { @Override public void close() throws IOException { if (mClosed) { return; } mLocalOutputStream.close(); String path = getUploadPath(); try { ObjectMetadata meta = new ObjectMetadata(); if (mSseEnabled) { meta.setSSEAlgorithm(ObjectMetadata.AES_256_SERVER_SIDE_ENCRYPTION); } if (mHash != null) { meta.setContentMD5(new String(Base64.encode(mHash.digest()))); } meta.setContentLength(mFile.length()); meta.setContentType(Mimetypes.MIMETYPE_OCTET_STREAM); PutObjectRequest putReq = new PutObjectRequest(mBucketName, path, mFile).withMetadata(meta); mManager.upload(putReq).waitForUploadResult(); } catch (Exception e) { LOG.error("Failed to upload {}: {}", path, e.toString()); throw new IOException(e); } finally { if (!mFile.delete()) { LOG.error("Failed to delete temporary file @ {}", mFile.getPath()); } mClosed = true; } } S3AOutputStream(String bucketName, String key, TransferManager manager,
      List<String> tmpDirs, boolean sseEnabled); @Override void write(int b); @Override void write(byte[] b); @Override void write(byte[] b, int off, int len); @Override void flush(); @Override void close(); }
S3AOutputStream extends OutputStream { @Override public void close() throws IOException { if (mClosed) { return; } mLocalOutputStream.close(); String path = getUploadPath(); try { ObjectMetadata meta = new ObjectMetadata(); if (mSseEnabled) { meta.setSSEAlgorithm(ObjectMetadata.AES_256_SERVER_SIDE_ENCRYPTION); } if (mHash != null) { meta.setContentMD5(new String(Base64.encode(mHash.digest()))); } meta.setContentLength(mFile.length()); meta.setContentType(Mimetypes.MIMETYPE_OCTET_STREAM); PutObjectRequest putReq = new PutObjectRequest(mBucketName, path, mFile).withMetadata(meta); mManager.upload(putReq).waitForUploadResult(); } catch (Exception e) { LOG.error("Failed to upload {}: {}", path, e.toString()); throw new IOException(e); } finally { if (!mFile.delete()) { LOG.error("Failed to delete temporary file @ {}", mFile.getPath()); } mClosed = true; } } S3AOutputStream(String bucketName, String key, TransferManager manager,
      List<String> tmpDirs, boolean sseEnabled); @Override void write(int b); @Override void write(byte[] b); @Override void write(byte[] b, int off, int len); @Override void flush(); @Override void close();  }