1. The difference between storageclient and StorageClient1
Believe that the use of Happy_fish Fastdfs children's shoes, must be familiar with storageclient, or you are familiar with the StorageClient1, what is the difference between them?
As we have already learned in the previous few posts, Fastdfs stores a file with Fastdfs stored in a certain storage path of a group. If you set up a two-tier directory structure on the storage server, the file ID that is uploaded to Fastdfs after a document is generally shaped like "group1/m01/00/2a/rbasvk8ory2nf9eoaairko2da7u901.jpg Form The "group1" is called the group name, and the "M01/00/08/rbasvk8ory2nf9eoaalrko2da7u901.jpg" in the latter segment is called the file name.
Knowing this, we can discuss the difference between storageclient and StorageClient1. In Storageclient, the file ID is represented by the group name and the file name, while the STORAGECLIENT1 group name and file name are processed together. In fact, through the analysis of Fastdfs Java client source code can be found, StorageClient1 is a subclass of Storageclient.
[Java]View Plaincopyprint?
- Public class StorageClient1 extends Storageclient {
- ...
- }
public class StorageClient1 extends Storageclient { ...}
StorageClient1 in Upload_file1 (...) The implementation of the method is called This.upload_file (...), and the returned group name and file name are combined to return.
2, a variety of file upload interface
Currently the latest version of the Fastdfs Java Client API is 1.19, which has the following upload APIs (storage Client1, for example):
[Java]View Plaincopyprint?
- /* Method 1*/upload_file1 (byte[] File_buff, String file_ext_name, namevaluepair[] meta_list);
- /* Method 2*/upload_file1 (String group_name, byte[] file_buff, String file_ext_name, namevaluepair[] meta_list);
- /* Method 3*/upload_file1 (String master_file_id, String prefix_name, byte[] file_buff, int offset, int length, String File_ext_name, namevaluepair[] meta_list);
- /* Method 4*/upload_file1 (String master_file_id, String prefix_name, byte[] file_buff, String file_ext_name, Namevaluepair[] meta_list);
- /* Method 5*/upload_file1 (String group_name, long file_size, Uploadcallback callback, String file_ext_name, Namevaluepair[] meta_list);
- /* Method 6*/upload_file1 (String master_file_id, String prefix_name, long file_size, Uploadcallback callback, string file _ext_name, namevaluepair[] meta_list);
- /* Method 7*/upload_file1 (String local_file_name, String file_ext_name, namevaluepair[] meta_list);
- /* Method 8*/upload_file1 (String group_name, String local_file_name, String file_ext_name, namevaluepair[] meta_list);
- /* Method 9*/upload_file1 (String master_file_id, String prefix_name, String local_file_name, String file_ext_name, Namevaluepair[] meta_list);
/* Method 1*/upload_file1 (byte[] file_buff, String file_ext_name, namevaluepair[] meta_list);/* Method 2*/upload_file1 (string Group_name, byte[] file_buff, String file_ext_name, namevaluepair[] meta_list);/* Method 3*/upload_file1 (String master_file _id, String prefix_name, byte[] file_buff, int offset, int length, String file_ext_name, namevaluepair[] meta_list);/* method /upload_file1 (String master_file_id, String prefix_name, byte[] file_buff, String file_ext_name, namevaluepair[] Meta_ list);/* Method 5*/upload_file1 (String group_name, Long file_size, Uploadcallback callback, String file_ext_name, Namevaluepair[] meta_list);/* Method 6*/upload_file1 (String master_file_id, String prefix_name, long file_size, Uploadcallback callback, String file_ext_name, namevaluepair[] meta_list);/* Method 7*/upload_file1 (String local_file_name , string file_ext_name, namevaluepair[] meta_list);/* Method 8*/upload_file1 (String group_name, String local_file_name, String file_ext_name, namevaluepair[] meta_list);/* Method 9*/upload_file1 (String Master_file_id, String prefix_name, String local_file_name, String file_ext_name, namevaluepair[] meta_list);
(1) Multiple upload formats
Method 1-4 uploads the file Buffer (byte array), and method 5-6 uploads the stream via a callback (explained in a later article), and method 7-9 uploads the local file.
(2) Multiple upload methods
Below, we will summarize the parameters of the interface for uploading, so that we could use the API easily.
|
Group Name |
Extension |
Meta List |
Master File ID |
Prefix Name |
Offset |
Length |
Size |
Format |
Method 1 |
|
√ |
√ |
|
|
|
|
|
Buffer |
Method 2 |
√ |
√ |
√ |
|
|
|
|
|
Buffer |
Method 3 |
|
√ |
√ |
√ |
√ |
√ |
√ |
|
Buffer |
Method 4 |
|
√ |
√ |
√ |
√ |
|
|
|
Buffer |
Method 5 |
√ |
√ |
√ |
|
|
|
|
√ |
Stream |
Method 6 |
|
√ |
√ |
√ |
√ |
|
|
√ |
Stream |
Method 7 |
|
√ |
√ |
|
|
|
|
|
Local |
Method 8 |
√ |
√ |
√ |
|
|
|
|
|
Local |
Method 9 |
|
√ |
√ |
√ |
√ |
|
|
|
Local |
All methods can carry parameters extension and meta list. In addition, the file size parameter must be given in the way of the callback upload stream.
StorageClient1 Upload Method, the return value is String,storageclient upload method, the return value is string[].
FASTDFS configuration, deployment, and API usage interpretation (8) Fastdfs multiple file Upload interface detailed