Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/34.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript mongoose-attachments-aws2js上传目录_Javascript_Node.js_Mongoose_Mongoose Plugins - Fatal编程技术网

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目录,并为所有附件保留一个模式