Skip to content

coding4m/fastdfs-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

60 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fastdfs-client

fastdfs-client is a FastDFS java client based on Netty 4 . support multiple tracker server pool and active tracker server health check .

Requirements

  • Java 8+

Usage

    
    // FastdfsClient is threadsafe and use connection pool.
    FastdfsClient  client = FastdfsClient.newBuilder()
                                            .connectTimeout(3000)
                                            .readTimeout(100)
                                            .healthCheck(3, 2, 3000, 10000)
                                            .tracker("192.168.1.2", 22222)
                                            .build();
    
    // upload file
    CompletableFuture<FileId> promise = client.upload(new File("/tmp/test.dmg"));
    FileId fileId = promise.get();
    // do something.
    
    // download file
    OutputStream out = ...
    CompletableFuture<Void> promise = client.download(fileId, out);
    // promise.whenComplete(...);
    
    // delete file
    CompletableFuture<Void> promise = client.delete(fileId);
    // promise.whenComplete(...);
    
    // get file info
    CompletableFuture<FileInfo> promise = client.infoGet(fileId);
    FileInfo fileInfo = promise.get();
    // do something.
    
    // set file metadata
    FileMetadata metadata = FileMetadata.newBuilder().put("test", "test1").build();
    CompletableFuture<Void> promise = client.metadataSet(fileId, metadata);
    // do something.
    
    // get file metadata
    CompletableFuture<FileMetadata> promise = client.metadataGet(fileId);
    FileMetadata metadata = promise.get();
    // do something.
    
    client.close();

Releases

No releases published

Packages

No packages published

Languages