Add this section to your repository configuration
<repositories>
<repository>
<id>vfs-s3.repository</id>
<name>vfs-s3 project repository</name>
<url>http://dl.bintray.com/content/abashev/vfs-s3</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
And use it as dependency
<dependency>
<groupId>com.github</groupId>
<artifactId>vfs-s3</artifactId>
<version>2.4.0</version>
</dependency>
We need this patched version of commons-vfs because some concurrency issues could be solved only internally
Branch | Build Status |
---|---|
commons-vfs2 | |
vfs-s3 |
- Merge changes back to
commons-vfs
project
// Create bucket
FileSystemManager fsManager = VFS.getManager();
FileObject dir = fsManager.resolveFile("s3://simple-bucket/test-folder/");
dir.createFolder();
// Upload file to S3
FileObject dest = fsManager.resolveFile("s3://test-bucket/backup.zip");
FileObject src = fsManager.resolveFile(new File("/path/to/local/file.zip").getAbsolutePath());
dest.copyFrom(src, Selectors.SELECT_SELF);
For running tests you need active credentials for AWS. You can specify them as
-
Shell environment properties
export AWS_ACCESS_KEY=AAAAAAA export AWS_SECRET_KEY=SSSSSSS
-
Or any standard ways how to do it in AWS SDK (iam role and so on)
Make sure that you never commit your credentials!
This code is based on http://code.google.com/p/vfs-s3/ which is no longer supported.