npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@charbo/ufile-node-sdk

v1.3.3

Published

UFile SDK for NodeJS

Downloads

21

Readme

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

| Param | Type | Description | | --- | --- | --- | | publicKey | string | api公钥 | | privateKey | string | api私钥 | | bucket | string | 存储空间名 | | domain | string | 存储空间域名 | | protocol | boolean | 网络协议头 |

uFile.setProps(props) ⇒ UFile

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

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

| Param | Type | Description | | --- | --- | --- | | props | Object | ufile配置参数 |

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

前缀列表查询

Kind: instance method of UFile

| Param | Type | Description | | --- | --- | --- | | prefix | string | 前缀,utf-8编码 | | marker | string | 标志字符串,utf-8编码 | | limit | number | 文件列表数目,默认为20 |

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

秒传文件

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

| Param | Type | Description | | --- | --- | --- | | key | string | 文件key,会屏蔽prefix和fileRename | | filePath | string | 待上传文件的路径 | | prefix | string | 文件前缀 | | fileRename | string | 重命名文件名(若无后缀会自动加上后缀) | | unique | Boolean | string | Number | 是否唯一,若传入ture则自动生成id,若传入Number或string则将其作为id |

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

上传文件

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

| Param | Type | Description | | --- | --- | --- | | key | string | 文件key,会屏蔽prefix和fileRename | | filePath | string | 待上传文件的路径 | | prefix | string | 文件前缀 | | fileRename | string | 重命名文件名(若无后缀会自动加上后缀) | | unique | Boolean | string | Number | 是否唯一,若传入ture则自动生成id,若传入Number或string则将其作为id |

uFile.getFile(key) ⇒ Object

下载文件

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

| Param | Type | Description | | --- | --- | --- | | key | string | key |

uFile.transferFile(urlArr) ⇒ Array

文件转移

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

| Param | Type | Description | | --- | --- | --- | | urlArr | Array | 源文件链接数组,数组元素可为字符串或对象 |

uFile.headFile(key) ⇒ Object

查询文件基本信息

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

| Param | Type | | --- | --- | | key | string |

uFile.deleteFile(key) ⇒ Object

删除文件

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

| Param | Type | | --- | --- | | key | string |

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

发送请求

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

| Param | Type | Description | | --- | --- | --- | | url | string | 请求的url,会屏蔽key | | method | string | 请求方法 | | headers | string | 请求头 | | key | string | 请求key | | query | string | 查询参数 | | body | string | 请求体 |

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

生成签名

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

| Param | Type | Description | | --- | --- | --- | | method | string | 请求方法 | | headers | string | 请求头 | | bucket | string | 资源bucket | | key | string | 请求key | | body | string | 请求体 |

uFile.initiateMultipartUpload(key) ⇒ Promise

初始化分片上传

Kind: instance method of UFile

| Param | Type | Description | | --- | --- | --- | | key | string | 文件名 |

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

上传分片

Kind: instance method of UFile

| Param | Type | Description | | --- | --- | --- | | key | string | 文件名 | | uploadId | string | 分片id | | partNumber | number | 第几块分片 | | buffer | buffer | 内容 |

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

完成分片

Kind: instance method of UFile

| Param | Type | Description | | --- | --- | --- | | key | string | 文件名 | | uploadId | string | 分片id | | [newKey] | string | 等上传完毕开始指定的key可能已经被占用,遇到这种情形时会采用newKey参数的值作为文件最终的key,否则仍然采用原来的key | | parts | array | 分片的etag们 |

uFile.abortMultipartUpload(key, uploadId) ⇒ Promise

放弃分片

Kind: instance method of UFile

| Param | Type | Description | | --- | --- | --- | | key | string | 文件名 | | uploadId | string | 分片id |

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

获取正在执行的分片上传

Kind: instance method of UFile

| Param | Type | Default | Description | | --- | --- | --- | --- | | [prefix] | string | | 前缀,utf-8编码,默认为空字符串 | | [marker] | string | | 标志字符串,utf-8编码,默认为空字符串 | | [limit] | number | 20 | id列表数目,默认为20 |

uFile.getMultiUploadPart(uploadId) ⇒ Promise

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

Kind: instance method of UFile

| Param | Type | Description | | --- | --- | --- | | uploadId | string | 上传id |

uFile.opMeta(key, mimeType) ⇒ Promise

操作文件的Meta信息

Kind: instance method of UFile

| Param | Type | Description | | --- | --- | --- | | key | string | key | | mimeType | string | 文件的mimetype |