NFS Guide

fengmk2 edited this page Oct 17, 2018 · 24 revisions support custom storage, but all the storage need follow the rules:


  • async function upload(filepath, options)
    • filepath: upload file path
    • options
      • key: identifie of this file
      • size: file size
  • async function uploadBuffer(fileBuffer, options)
    • fileBuffer: upload file content buffer
    • options
      • key: identifie of this file
      • size: fileBuffer size
      • shasum: fileBuffer sha1
      • shasum256: fileBuffer sha256
  • async function remove(key)
    • key: file identifie
  • async function download(key, savePath, options)[optional]
    • key: file identifie
    • savePath: download path
    • options
      • timeout
  • async function createDownloadStream(key, options)[optional]
    • key: file identifie
    • options
      • timeout
    • return {ReadStream}
  • async function url(key)[optional] url method should be async function too.
    • key: file identifie

All function are async function.

Support Storage Types

  1. Can download the uploaded file through http request. like qn-cnpm.
  • uploadBuffer: use options.key to customize the filename, then callback {url: ''}.
  • url: accept a key and respond download url.
  • remove: remove file by key
  1. Can not download by http request. like sfs-client or oss-cnpm.
  • uploadBuffer: upload the file, and must callback {key: 'xxx'}, so can record the key, and use this key to download or remove.
  • download: need provide download api to download the file by key.
  • createDownloadStream: streaming download file by key
  • remove: remove file by key

Present Storage wrappers

  • fs: A filesystem storage wrapper
  • sfs: A wrapper for a simple distribute file storage system sfs
  • qn: qiniu cloud storage service wrapper
  • oss: ali oss storage service wrapper
  • upyun: upyun cloud storage service wrapper
  • cos: cos Qcloud Cloud Object Storage
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.