- 安装 ali-oss:
yarn add ali-oss
- 连接 OSS:
const client = new OSS({
accessKeyId: 'xxx',
accessKeySecret: 'yyy',
bucket: 'your-bucket',
region: 'oss-cn-hangzhou',
})
- 上传文件
put(路径,Buffer)
const buf = await promisify(readFile)('./hello.txt')
await client.put(`/dir/test.txt`, buf)