Javascript mongoose-attachments-aws2js上传目录
我有一个附件的模式:Javascript mongoose-attachments-aws2js上传目录,javascript,node.js,mongoose,mongoose-plugins,Javascript,Node.js,Mongoose,Mongoose Plugins,我有一个附件的模式: 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 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目录,并为所有附件保留一个模式