Skip to content
This repository was archived by the owner on Jun 2, 2024. It is now read-only.

NFS Guide

fengmk2 edited this page Jan 14, 2014 · 30 revisions

cnpmjs.org support custom nfs, but all the nfs need follow the rules:

APIs

  • upload(filePath, options, callback):
  • uploadBuffer(fileBuffer, options, callback)
  • remove(key)
  • url(key)[optional]
  • downloadStream(key, writeStream, options, callback)[optional]
  • download(key, savePath, options, callback)[optional]

PS: cnpm will try to use downloadStream() first.

Support NFS Types

  1. Can custom the filename by key, and download by http request. see qnfs.
  • upload and uploadBuffer use options.key to custom the filename, then callback {url: 'http://test.com/xxx.tgz'}.
  • url use key to generate a download url.
  1. Random filename, and can not download by http request. see tfs-cnpm or sfs-client.
  • upload and uploadBuffer upload the file, and must callback {key: 'xxx'}, so cnpmjs.org can record the key, and use this key to download or remove.
  • Must implement downloadStream or download api to download the file by key.
  1. Random filename, and can download by http request.
  • upload and uploadBuffer callback {url: 'http://test.com/xxx.tgz'}, so cnpmjs.org can record the url, when user request this module, we will redirect them to this url.

Clone this wiki locally