npm install fastdfsl-client
// -------------------------------- -------------- profile ---------------------------------- the let the require FdfsClient = ( 'FastDFS-Client'); the let new new FDFS = FdfsClient ({ // Tracker Servers trackers: [ { Host: .233.50.185 '49 ', Port: 22122 } ], // default timeout 10s timeout: 10000, // default suffix // not used when acquiring the file extension defaultExt : 'TXT', // default charset UTF8 charset: 'UTF8' }); // ------------------------------ --upload files---------------------------------------------- ---- // fdfs.upload ( 'E: \\ wsl1.jpeg', { // // upload method [upload, uploadAppender, append, modify ], defaults to upload Method //: 'Upload', // // the specified file stored in the group, not specified by the tracker server assigned // Group: 'named group1', // // Method to modify or append additional source file specified // fileId : 'group1 / M00 / 00 / 0F / wKgBeFXlZJuAdsBZAAPm5H9JxDA153.jpg', // // file bytes, file parameter must be specified when readableStream // size: 1024, // // Method, modify the source file to specify additional starting point offset //: 10240, // // suffix upload files, do not specify the parameters acquired file suffix, excluding (.) // EXT: 'JPG' //}) the then (function (fileId) {. // // fileId + for the Group '/' + filename // console.log ( "upload pictures of return ==============> fileId as a group + '/' + filename: === >> === "fileId +); //}); ====== >> "+ fileId); // }).catch(function(err) { Console.error // (ERR); // -------------------------------- ----- delete files --------------------------------------------- // the let fileId = "group1 / M00 / 00/00 / rBUACF2B-E-AdwypAAHlUvTq5Uw301.jpg"; // fdfs.del (fileId) .then (function () { // console.log ( "deleted successfully: ======= >> = ") .} //) the catch (function (ERR) { // console.error (" deletion failed: ======= >> ", ERR +); //}); // - --------------------------------View Files---------------- ---------------------------------- // the let fileId = "group1 / M00 / 00/00 / rBUACF2B8- eARPdgAAHlUvTq5Uw20.jpeg "; // fdfs.getFileInfo (fileId) .then (function (the fileInfo) { // // the fileInfo has four attributes // {// // // // file size // // size: // // // file creation time of stamp, in seconds Timestamp // //: // // // checksum // // CRC32: // // // first uploaded to the storage server's IP // // addr: //} // // Console. log ({ // "size": fileInfo.size, // "timestamp": fileInfo.timestamp, // "CRC32": fileInfo.crc32, // "addr": fileInfo.addr, //}); // .}) the catch (function (ERR) { // console.error (ERR); //}); // ------------------------ ----------download file-------------------------------------- -------- //}).catch(function(err) { // console.error(err); // the let fileId = "group1 / M00 / 00/00 / rBUACF2B96CAf2NpAAHlUvTq5Uw32.jpeg"; Fdfs.download // (fileId, 'test_download.gif') the then (function () {. // the console.log ( "download completed") //});