任何人都可以告诉我如何使用npm papercut从amazon s3存储中删除/删除/取消链接图像/文件 https://www.npmjs.org/package/papercut
我已使用以下代码成功上传了图片/文件:
var papercut = require('papercut');
papercut.configure('production', function(){
papercut.set('storage', 's3')
papercut.set('S3_KEY', process.env.S3_KEY)
papercut.set('S3_SECRET', process.env.S3_SECRET)
papercut.set('bucket', 'papercut')
});
AvatarUploader = papercut.Schema(function(schema){
schema.version({
name: 'avatar',
size: '200x200',
process: 'crop'
});
schema.version({
name: 'small',
size: '50x50',
process: 'crop'
});
});
uploader = new AvatarUploader();
uploader.process('image1', file.path, function(images){
console.log(images.avatar); // '/images/uploads/image1-avatar.jpg'
console.log(images.small); // '/images/uploads/image1-small.jpg'
})
但删除用户个人资料时无法再次取消链接/删除图像
答案 0 :(得分:2)
首先你需要knox模块,然后
var knox = require('knox');
var client = knox.createClient({
key: S3_KEY,
secret: S3_SECRET,
bucket: BUCKET_NAME
});
client.deleteFile(imgPath, function(err, res){
console.log('Clip delete err :',err,', Clip path :',imgPath);
});
imgPath = s3 image url.
你去......