const OSS = require('ali-oss')
let client = new OSS({
        region: 'oss-cn-najing',
        accessKeyId: 'youid',
        accessKeySecret: 'yoursecret',
        bucket: 'yourbucket',
        secure:true //    secure:配合region使用。如果指定securetrue,则使用 HTTPS 访问,不配置,调用下面get方法,则看到为htttp开头
});
//删除图片
async function del(url) {
    let result = await client.delete(url);
}
//获取图片
async function get(url) {
    let result = await client.get(url);
}
则  const url ='20170909/pictures/156289727680779.png';//object-name
     get(url);
    nodejs 阿里oss删除图片

 

     del(url)
删除后在访问图片,
<Error>
<Code>NoSuchKey</Code>
<Message>The specified key does not exist.</Message>
<RequestId>5D29DF5FAE3689BFBB2CBA5B</RequestId>
<HostId>yourbuket.oss-cn-nanjing.aliyuncs.com</HostId>
 </Error>

 

 

相关文章:

  • 2022-12-23
  • 2021-05-08
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-06-09
  • 2021-12-18
  • 2021-12-18
  • 2021-12-18
  • 2021-12-18
相关资源
相似解决方案