我有一个附件架构:
var mongoose = require('mongoose');
var s3 = require('./config/secrets').s3;
var provider = require('mongoose-attachments-aws2js');
var attachments = require('mongoose-attachments');
attachments.registerStorageProvider('aws2js', provider);
var attachmentSchema = new mongoose.Schema({
name: String,
date_created: {type: Date, default: new Date()},
is_active: {type: Boolean, default: true}
});
attachmentSchema.plugin(attachments, {
directory: 'HowToChangeThis',
storage : {
providerName: 'aws2js',
options: {
key: s3.key,
secret: s3.secret,
bucket: s3.bucket,
acl: 'public-read'
}
},
properties: {
file: {
styles: {
original: {
// keep the original file
}
}
}
}
});
module.exports = mongoose.model('Attachment', attachmentSchema);
此模式在不同的文档中使用:事件(附件是事件图像)、用户(附件是头像)、位置(附件是位置照片)等。但我不想将所有附件上传到 1 个远程目录. 有没有办法动态更改 mongoose-attachments-aws2js 目录并为所有附件只保留 1 个模式?