Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,47 @@ ConnectionProperties connectionProperties
.host("localhost")
.port(9333)
.maxConnection(100).build();
// Apply properties
fileSource.setProperties(connectionProperties);
// Startup manager and listens for the change
fileSource.startup();
```

##### Create a file operation template
[SeaWeed Write Protocol](https://github.com/chrislusf/seaweedfs#write-file)
```java
// Template used with connection manager
FileTemplate template = new FileTemplate(fileSource.getConnection());

template.saveFileByStream("filename.doc", someFile);
```

##### Fetch a files content
[SeaWeed Read Protocol](https://github.com/chrislusf/seaweedfs#read-file)
```java
// This is the value returned by assign (dir/assign) when you write a file
// https://github.com/chrislusf/seaweedfs#write-file
String fileId = "3,01637037d6";

FileTemplate template = new FileTemplate(fileSource.getConnection());

StreamResponse fileStream = template.getFileStream(fileId);
// Will print the content within the file
System.out.println("File Content: " + fileStream.getOutputStream());
```

##### Fetching File Handlers (Name, Size, LastModified, Content Type)
```java
// This is the value returned by assign (dir/assign) when you write a file
// https://github.com/chrislusf/seaweedfs#write-file
String fileId = "3,01637037d6";

FileTemplate template = new FileTemplate(fileSource.getConnection());

FileHandleStatus fileStatus = template.getFileStatus(fileHandleStatus.getFileId());
System.out.println("File Name: " + fileStatus.getFileName());
```

## License

The Apache Software License, Version 2.0
Expand Down
16 changes: 12 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,8 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jackson.version>2.10.3</jackson.version>
<httpclient.version>4.5.10</httpclient.version>
<ehcache.version>3.1.1</ehcache.version>
<jackson.version>2.11.1</jackson.version>
<httpclient.version> 4.5.12</httpclient.version>
<spring.version>4.3.1.RELEASE</spring.version>
<junit.version>4.11</junit.version>
</properties>
Expand Down Expand Up @@ -110,6 +109,15 @@
<version>28.2-jre</version>
</dependency>

<!-- Caching tool (Like guava but better performance) -->
<dependency>
<groupId>com.github.ben-manes.caffeine</groupId>
<artifactId>caffeine</artifactId>
<version>2.8.5</version>
</dependency>



</dependencies>
<build>
<plugins>
Expand Down Expand Up @@ -138,4 +146,4 @@
</plugin>
</plugins>
</build>
</project>
</project>