1.3.3 • Published 4 years ago

@charbo/ufile-node-sdk v1.3.3

Weekly downloads
14
License
MIT
Repository
github
Last release
4 years ago

ufile-node-sdk

ufile官方的Node SDK改进

(分片上传及bucket操作暂未实现,请勿使用)

接口参数和返回参考https://docs.ucloud.cn/api/ufile-api/index

API配置:在根目录创建 ufile-config.json或直接在初始化时传值

UFile

Kind: global class

new UFile(publicKey, privateKey, bucket, domain, protocol)

UFile SDK

ParamTypeDescription
publicKeystringapi公钥
privateKeystringapi私钥
bucketstring存储空间名
domainstring存储空间域名
protocolboolean网络协议头

uFile.setProps(props) ⇒ UFile

返回一个修改部分参数的UFile对象

Kind: instance method of UFile
Returns: UFile - 新的UFile对象

ParamTypeDescription
propsObjectufile配置参数

uFile.getPrefixFileList(prefix, marker, limit) ⇒ Promise

前缀列表查询

Kind: instance method of UFile

ParamTypeDescription
prefixstring前缀,utf-8编码
markerstring标志字符串,utf-8编码
limitnumber文件列表数目,默认为20

uFile.uploadHit(key, filePath, prefix, fileRename, unique) ⇒ Object

秒传文件

Kind: instance method of UFile
Returns: Object - 状态码及上传成功的资源路径

ParamTypeDescription
keystring文件key,会屏蔽prefix和fileRename
filePathstring待上传文件的路径
prefixstring文件前缀
fileRenamestring重命名文件名(若无后缀会自动加上后缀)
uniqueBoolean | string | Number是否唯一,若传入ture则自动生成id,若传入Number或string则将其作为id

uFile.putFile(key, filePath, prefix, fileRename, unique) ⇒ Object

上传文件

Kind: instance method of UFile
Returns: Object - 状态码及上传成功的资源路径

ParamTypeDescription
keystring文件key,会屏蔽prefix和fileRename
filePathstring待上传文件的路径
prefixstring文件前缀
fileRenamestring重命名文件名(若无后缀会自动加上后缀)
uniqueBoolean | string | Number是否唯一,若传入ture则自动生成id,若传入Number或string则将其作为id

uFile.getFile(key) ⇒ Object

下载文件

Kind: instance method of UFile
Returns: Object - 状态码及文件保存路径

ParamTypeDescription
keystringkey

uFile.transferFile(urlArr) ⇒ Array

文件转移

Kind: instance method of UFile
Returns: Array - 转移后的资源路径

ParamTypeDescription
urlArrArray源文件链接数组,数组元素可为字符串或对象

uFile.headFile(key) ⇒ Object

查询文件基本信息

Kind: instance method of UFile
Returns: Object - API响应头

ParamType
keystring

uFile.deleteFile(key) ⇒ Object

删除文件

Kind: instance method of UFile
Returns: Object - 状态码和状态信息

ParamType
keystring

uFile._sendRequest(url, method, headers, key, query, body) ⇒ request | Promise

发送请求

Kind: instance method of UFile
Returns: request | Promise - 状态码和状态信息

ParamTypeDescription
urlstring请求的url,会屏蔽key
methodstring请求方法
headersstring请求头
keystring请求key
querystring查询参数
bodystring请求体

uFile._sign(method, headers, bucket, key, body) ⇒ request | Promise

生成签名

Kind: instance method of UFile
Returns: request | Promise - 状态码和状态信息

ParamTypeDescription
methodstring请求方法
headersstring请求头
bucketstring资源bucket
keystring请求key
bodystring请求体

uFile.initiateMultipartUpload(key) ⇒ Promise

初始化分片上传

Kind: instance method of UFile

ParamTypeDescription
keystring文件名

uFile.uploadPart(key, uploadId, partNumber, buffer) ⇒ Promise

上传分片

Kind: instance method of UFile

ParamTypeDescription
keystring文件名
uploadIdstring分片id
partNumbernumber第几块分片
bufferbuffer内容

uFile.finishMultipartUpload(key, uploadId, newKey, parts) ⇒ Promise

完成分片

Kind: instance method of UFile

ParamTypeDescription
keystring文件名
uploadIdstring分片id
newKeystring等上传完毕开始指定的key可能已经被占用,遇到这种情形时会采用newKey参数的值作为文件最终的key,否则仍然采用原来的key
partsarray分片的etag们

uFile.abortMultipartUpload(key, uploadId) ⇒ Promise

放弃分片

Kind: instance method of UFile

ParamTypeDescription
keystring文件名
uploadIdstring分片id

uFile.getMultiUploadId(prefix, marker, limit) ⇒ Promise

获取正在执行的分片上传

Kind: instance method of UFile

ParamTypeDefaultDescription
prefixstring前缀,utf-8编码,默认为空字符串
markerstring标志字符串,utf-8编码,默认为空字符串
limitnumber20id列表数目,默认为20

uFile.getMultiUploadPart(uploadId) ⇒ Promise

获取已上传成功的分片列表

Kind: instance method of UFile

ParamTypeDescription
uploadIdstring上传id

uFile.opMeta(key, mimeType) ⇒ Promise

操作文件的Meta信息

Kind: instance method of UFile

ParamTypeDescription
keystringkey
mimeTypestring文件的mimetype
1.3.3

4 years ago

1.3.2

4 years ago

1.3.1

4 years ago

1.3.0

4 years ago

1.2.2

4 years ago

1.2.1

5 years ago

1.2.0

5 years ago

1.1.3

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago