const OSS = require('ali-oss')
let client = new OSS({
region: 'oss-cn-najing',
accessKeyId: 'youid',
accessKeySecret: 'yoursecret',
bucket: 'yourbucket',
secure:true // secure:配合
region
使用。如果指定secure
为true
,则使用 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);
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>
<Key>20170909/pictures/156289727680779.png</Key>
</Error>