https://github.com/bytemechanics/s3-nio-filesystem
S3 NIO2 filesystem implementation
https://github.com/bytemechanics/s3-nio-filesystem
filesystem java library s3
Last synced: about 1 year ago
JSON representation
S3 NIO2 filesystem implementation
- Host: GitHub
- URL: https://github.com/bytemechanics/s3-nio-filesystem
- Owner: bytemechanics
- License: apache-2.0
- Created: 2018-03-05T06:55:08.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2021-12-14T12:49:00.000Z (over 4 years ago)
- Last Synced: 2025-02-12T06:24:25.463Z (over 1 year ago)
- Topics: filesystem, java, library, s3
- Language: Java
- Homepage: https://s3-nio-filesystem.bytemechanics.org
- Size: 70.3 KB
- Stars: 4
- Watchers: 3
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# S3 NIO Filesystem
[](https://maven-badges.herokuapp.com/maven-central/org.bytemechanics.filesystem/s3-nio-filesystem/badge.svg)
[](https://sonarcloud.io/dashboard/index/org.bytemechanics.filesystem%3As3-nio-filesystem)
[](https://sonarcloud.io/dashboard/index/org.bytemechanics.filesystem%3As3-nio-filesystem)
[](https://opensource.org/licenses/Apache-2.0)
S3 Filesystem is a library to convert S3 protocol to a NIO2 filesystem
Warning: This library does not accomplish the zero-dependencies objective
## Motivation
Utility to test the concept of create a virtual filesystem from s3 service
## Quick start
1. First of all include the Jar file in your compile and execution classpath.
### Maven
```Maven
org.bytemechanics.filesystem
s3-nio-filesystem
X.X.X
```
### Graddle
```Gradle
dependencies {
compile 'org.bytemechanics.filesystem:s3-nio-filesystem:X.X.X'
}
```
1. Create filesystem
```Java
package mypackage;
import java.net.URI;
import java.net.URLEncoder;
import java.nio.file.FileSystem;
import java.nio.file.FileSystems;
import java.text.MessageFormat;
import java.util.HashMap;
import java.util.Map;
public class S3FileSystemTest {
private static final String S3URI="s3://{0}:{1}@192.168.56.1:9000";
private static final String S3USER="9OIA67H2VBDP5T62ZCHK";
private static final String S3PASSWORD="7a0iE4IHHeE5Curn8SJJG7Xe5a3plQ/YZ5sgedEM";
private static final String S3BUCKET="es-spl";
private static final long PROPERTY_MULTIPART_UPLOAD_MINSIZE=Long.MAX_VALUE;
private static final long PROPERTY_CONNECTION_TIMEOUT=100l;
private FileSystem fileSystem;
public void S3FileSystemTest() throws IOException{
Map environment= new HashMap<>();
environment.put(S3FileSystemEnvironment.PROPERTY_MULTIPART_UPLOAD_MINSIZE.name(),String.valueOf(PROPERTY_MULTIPART_UPLOAD_MINSIZE));
environment.put(S3FileSystemEnvironment.PROPERTY_CONNECTION_TIMEOUT.name(),String.valueOf(PROPERTY_CONNECTION_TIMEOUT));
String encodedUser=URLEncoder.encode(S3USER,"UTF-8");
String encodedPassword=URLEncoder.encode(S3PASSWORD,"UTF-8");
URI uri=URI.create(MessageFormat.format("s3://{0}:{1}@192.168.56.1:9000/{2}",encodedUser,encodedPassword,S3BUCKET));
fileSystem=FileSystems.newFileSystem(uri,environment);
}
}
```
1. Get path from filesystem
```Java
Path path=this.fileSystem.getPath("test.pdf");
```
## Tested with
* Minio (https://www.minio.io/)
* Hitachi (https://www.hitachivantara.com/en-us/products/storage.object-storage.html#categorycontent)