This repository has been archived by the owner on Jun 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 746
NFS Guide
fengmk2 edited this page May 7, 2023
·
30 revisions
cnpmjs.org 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 beasync function
too.- key: file identifie
-
async function readBytes(key, options)[optional]
- key: file identifie
- options
- timeout
-
async function appendBuffer(fileBuffer, options)[optional]
- fileBuffer: upload file content buffer
- options
- key: identifie of this file
All function are async
function.
- Can download the uploaded file through http request. like qn-cnpm.
-
uploadBuffer
: useoptions.key
to customize the filename, then callback{url: 'http://test.com/xxx.tgz'}
. -
url
: accept akey
and respond download url. -
remove
: remove file by key
- Can not download by http request. like sfs-client or oss-cnpm.
-
uploadBuffer
: upload the file, and must callback{key: 'xxx'}
, so cnpmjs.org 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
- fs: A filesystem storage wrapper
- sfs: A wrapper for a simple distribute file storage system sfs
- qn: qiniu cloud storage service wrapper
- oss: alicloud oss storage service wrapper
- upyun: upyun cloud storage service wrapper
- cos: cos Qcloud Cloud Object Storage
- s3-cnpm: s3-cnpm Amazon S3 storage wrapper
- s3-cnpmcore: S3 storage wrapper for cnpmcore, see https://github.com/cnpm/cnpmcore/issues/353
Copyright @ 2013 - present cnpmjs.org