Saber2pr's Blog

UsingOssApiOnNodejs

  1. Install ali-oss: ali-oss documentation
yarn add ali-oss

two。 Connect to the OSS:

const client = new OSS({
  accessKeyId: 'xxx',
  accessKeySecret: 'yyy',
  bucket: 'your-bucket',
  region: 'oss-cn-hangzhou',
})
  1. Upload files

put (path, Buffer)

const buf = await promisify(readFile)('./hello.txt')
await client.put(`/dir/test.txt`, buf)