添付ファイルのスキーマがあります:
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 つのスキーマのみを保持する方法はありますか?