@Test void writeFile_forNewFile_writesFileContent() throws Exception { AmazonS3 amazonS3 = mock(AmazonS3.class); SimpleStorageResource simpleStorageResource = new SimpleStorageResource(amazonS3, "bucketName", "objectName", new SyncTaskExecutor()); String messageContext = "myFileContent"; when(amazonS3.putObject(eq("bucketName"), eq("objectName"), any(InputStream.class), any(ObjectMetadata.class))) .thenAnswer((Answer<PutObjectResult>) invocation -> { assertThat(invocation.getArguments()[0]) .isEqualTo("bucketName"); assertThat(invocation.getArguments()[1]) .isEqualTo("objectName"); byte[] content = new byte[messageContext.length()]; assertThat(((InputStream) invocation.getArguments()[2]) .read(content)).isEqualTo(content.length); assertThat(new String(content)).isEqualTo(messageContext); return new PutObjectResult(); }); OutputStream outputStream = simpleStorageResource.getOutputStream(); outputStream.write(messageContext.getBytes()); outputStream.flush(); outputStream.close(); }
@Override public OutputStream getOutputStream() throws IOException { return new SimpleStorageOutputStream(); }
SimpleStorageResource extends AbstractResource implements WritableResource { @Override public OutputStream getOutputStream() throws IOException { return new SimpleStorageOutputStream(); } }
SimpleStorageResource extends AbstractResource implements WritableResource { @Override public OutputStream getOutputStream() throws IOException { return new SimpleStorageOutputStream(); } SimpleStorageResource(AmazonS3 amazonS3, String bucketName, String objectName,
			TaskExecutor taskExecutor);  SimpleStorageResource(AmazonS3 amazonS3, String bucketName, String objectName,
			TaskExecutor taskExecutor, String versionId); }
SimpleStorageResource extends AbstractResource implements WritableResource { @Override public OutputStream getOutputStream() throws IOException { return new SimpleStorageOutputStream(); } SimpleStorageResource(AmazonS3 amazonS3, String bucketName, String objectName,
			TaskExecutor taskExecutor);  SimpleStorageResource(AmazonS3 amazonS3, String bucketName, String objectName,
			TaskExecutor taskExecutor, String versionId); @Override String getDescription(); @Override InputStream getInputStream(); @Override boolean exists(); @Override long contentLength(); @Override long lastModified(); @Override String getFilename(); @Override URL getURL(); URI getS3Uri(); @Override File getFile(); @Override boolean isWritable(); @Override OutputStream getOutputStream(); @Override SimpleStorageResource createRelative(String relativePath); AmazonS3 getAmazonS3(); }
SimpleStorageResource extends AbstractResource implements WritableResource { @Override public OutputStream getOutputStream() throws IOException { return new SimpleStorageOutputStream(); } SimpleStorageResource(AmazonS3 amazonS3, String bucketName, String objectName,
			TaskExecutor taskExecutor);  SimpleStorageResource(AmazonS3 amazonS3, String bucketName, String objectName,
			TaskExecutor taskExecutor, String versionId); @Override String getDescription(); @Override InputStream getInputStream(); @Override boolean exists(); @Override long contentLength(); @Override long lastModified(); @Override String getFilename(); @Override URL getURL(); URI getS3Uri(); @Override File getFile(); @Override boolean isWritable(); @Override OutputStream getOutputStream(); @Override SimpleStorageResource createRelative(String relativePath); AmazonS3 getAmazonS3();  }