有人知道如何使用sails.js的(输入,存在)格式将文件上传到控制器操作,这是我的尝试:
module.exports = {
friendlyName: 'Upload file recording',
description: 'Upload a recording to AWS',
inputs: {
name: {
required: true,
type: 'string'
},
mimeType: {
required: true,
type: 'string'
},
recording: {
type: 'ref'
}
},
exits: {
noRecordings: {
responseType: 'no recordings',
description: `You don't have any recording for this event`,
},
serverError: {
responseType: 'server error',
description: `Failed to upload the file`,
}
},
fn: async function (inputs, exits) {
// fixme
inputs.file('recording').upload({
adapter: require('skipper-s3'),
key: process.env.AWS_S3_KEY,
secret: process.env.AWS_S3_SECRET,
bucket: process.env.AWS_S3_BUCKETNAME
}, function (err, filesUploaded) {
if (err) return exits.serverError(err);
return exits.success({
files: filesUploaded,
textParams: req.allParams()
});
});
}
};
上传文件,因为inputs.file不是函数。基本上问题是,如何在这里传递文件。
感谢任何帮助。
答案 0 :(得分:2)
所以终于找到了解决方案,我只需要使用:
window.scroll
除了:
files: ['recording'],
然后在动作函数中:
inputs:
recording: {
example: '===',
required: true
},