阿里云的oss通过js操作


Ali-oss



当前最新版本6.0.0,支持 async/await,

"ali-oss": "^6.0.0", 
https://github.com/ali-sdk/ali-oss
https://help.aliyun.com/document_detail/32068.html


Oss判断文件已经存在

  • 如果存在那么返回json
const object = await client.head('ossdemo/head-meta');
console.log(object);

{
  status: 200,
  meta: {
    uid: '1',
    path: 'foo/demo.txt'
  },
  res: { ... }
}

  • 如果不存在那么抛异常。
Head a not exists object
const object = await client.head('ossdemo/head-meta');
// will throw NoSuchKeyError

阅读量: 343
发布于:
修改于: