一个Sumor Cloud工具。
更多文档
这是一个用于 Node.JS 的轻量级存储库。
它可以连接到各种存储服务,例如阿里云 OSS
npm i @sumor/storage --save
需要 Node.JS 版本 18.x 或以上
由于该包是用 ES 模块编写的,
请在您的 package.json
文件中修改以下代码:
{
"type": "module"
}
import { Storage } from '@sumor/storage'
const storage = new Storage(config)
阿里云 OSS 示例
{
"type": "aliyunOSS",
"accessKeyId": "xxxx",
"accessKeySecret": "xxx",
"region": "oss-us-west-1",
"bucket": "sumor-cloud"
}
存储内容支持文本、缓冲区、流
import { Storage } from '@sumor/storage'
const storage = new Storage(config)
const filename = 'demo.txt'
const content = 'Hello World'
const result = await storage.put(filename, content)
import { Storage } from '@sumor/storage'
const storage = new Storage(config)
const filename = 'demo.txt'
const result = await storage.get(filename)
import { Storage } from '@sumor/storage'
const storage = new Storage(config)
const filename = 'demo.txt'
const result = await storage.delete(filename)