我尝试使用edge:slingshot包在我的s3存储桶上传视频,它与图像文件一起使用但是有视频文件我有这样的错误:“错误:无法将文件上传到云端存储[ - 0 ] 跟踪:Meteor.makeErrorType/errorClass@http://localhost:3000/packages/meteor.js?9730f4ff059088b3f7f14c0672d155218a1802d4:525:15 getError @ http://localhost:3000/packages/edgee_slingshot.js?4c5b8e7dc4cae9d464984ead4903ef4beaac99f5:388:1 Slingshot.Upload /< .transfer /< @ http://localhost:3000/packages/edgee_slingshot.js?4c5b8e7dc4cae9d464984ead4903ef4beaac99f5:407:18“
我的模板活动:
Template.upload_vid.events({
'change input[type="file"]': function ( event, template ) {
var file = event.currentTarget.files[0];
Modules.client.uploadToAmazonS3( { file: file, template: template, type :"video" } );
}});
我的模板:
<template name="upload_vid">
<input type="file" name="file" id="file_vid">
<label for="file_vid">download</label>
</template>
我定义弹弓的功能(仅限服务器端的slingshot.js):
Slingshot.fileRestrictions( "uploadVidToAmazonS3", {
allowedFileTypes: [ "video/webm", "video/mp4", "video/mov", "video/3gp"],
maxSize: 50 * 1024 * 1024
});
Slingshot.createDirective( "uploadVidToAmazonS3", Slingshot.S3Storage, {
bucket: my_bucket,
acl: "public-read",
authorize: function () {
var user = Meteor.userId();
if(user){
return true;
} else {
return false;
}
},
key: function ( file ) {
var user = Meteor.users.findOne( this.userId );
return user.emails[0].address + "/video_profil/" + file.name;
}
});
和使用Slingshot的功能和上传(与图像一起正常工作):
let template;
let _uploadPicsToAmazon = ...
let _uploadVidToAmazon = ( file, type ) => {
var uploader = new Slingshot.Upload( "uploadVidToAmazonS3" );
uploader.send( file, ( error, url ) => {
if ( error ) {
console.log( error, "warning" );
} else {
console.log("success");
}
});
};
let upload = ( options ) => {
template = options.template;
let file = options.file;
let type = options.type;
if(type == "img"){
_uploadPicsToAmazon( file, type );
}else{
_uploadVidToAmazon( file, type );
}
};
Modules.client.uploadToAmazonS3 = upload;
任何人都有解决方案吗?先谢谢你。