FASTDFS configuration, deployment, and API usage interpretation (8) Fastdfs multiple file Upload interface detailed

Source: Internet
Author: User

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.

    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):

/* 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)  ;

(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 (RPM)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.