我正在尝试将用户 ID 从服务器传递FlowRouter.getParam('id');
到服务器以将文件上传到亚马逊。这是一个管理员帐户,因此我使用FlowRouter.getParam('id');
来访问正确的用户个人资料信息。问题是我没有正确传递 id,所以这一切都只是错误并停止工作。
如何正确传递 id?
小路uploadFile.js
let _uploadFileToAmazon = ( file ) => {
var id = FlowRouter.getParam('id');
const uploader = new Slingshot.Upload( "uploadProfileImgAdmin", id );
uploader.send( (file), ( error, url ) => {
if ( error ) {
Bert.alert( error.message, "warning" );
_setPlaceholderText();
} else {
_addUrlToDatabase( url );
}
});
};
小路server/uploadFile.js
Slingshot.createDirective( "uploadProfileImgAdmin", Slingshot.S3Storage, {
bucket: "bhr-app",
region: "ap-southeast-2",
acl: "public-read",
authorize: function (id) {
console.log("user id: ", id);
return Files.findOne( { "userId": id } );
},
key: function ( file ) {
var user = Meteor.users.findOne( _id: id );
return "profile-images" + "/" + user.emails[0].address + "/" + file.name;
}
});