FilesService
Hive SDK uploads files to the corresponding Vault through the FileService class - File is one of the data types supported by Hive SDK. The FileService class is one of the derived sub-services in Vault Service, which is used to support the operation of file types, such as uploading, downloading, and deleting. Once the data is uploaded to Hive Node, its file block data is hosted and saved in the corresponding IPFS Node, while its metadata information is hosted in the Vault internal database.
Upload File
Upload File Data by Writing File Stream Interface Writer
When uploading a file, you need to first get the FileSerivce interface instance from the Vault instance and then set the target path (REMOTE_FILE_PATH) to get the remote write file stream interface instance Writer. At the same time, write the file content into the file stream. The process of writing file data is the same as of uploading file data.
The whole process of uploading files by using the FileService instance is connected in series through the Promise mode - a Promise object is returned, which indicates whether the file upload succeeds, or the upload fails and an exception occurs.
An example of uploading files by using the write file stream interface is as follows:
Download File
Similar to uploading files, when downloading them, you can get the Reader or InputStream instance through the FileSerice instance, and then download the file data in the Vault based on the Reader instance or InputStream instance.
List
List the files in the file directory. FileInfo is single file information, and the path is the file directory.
Stat
Obtain the information of a single file.
Move
Move a single file from source to target.
Delete
Delete the file; the file is in path.
Last updated