I'm reading this documentation:
http://cloud.spring.io/spring-cloud-aws/spring-cloud-aws.html
on using AWS from a Spring application. I'm particularly interested in S3, so, I set up the application and copied this snippet of code to make sure the set up is working correctly:
Resource resource = this.resourceLoader.getResource("s3://myBucket/rootFile.log");
WritableResource writableResource = (WritableResource) resource;
try (OutputStream outputStream = writableResource.getOutputStream()) {
outputStream.write("test".getBytes());
}
but when I run it, I get this error:
java.lang.ClassCastException: org.springframework.web.context.support.ServletContextResource cannot be cast to org.springframework.core.io.WritableResource
Any ideas what's wrong? is that a setup problem? It doesn't look like to me, but I'm new to this.