2

I try to upload a video on my s3 bucket with edge:slingshot package, It's work fine with image file but with video file I have this error : "Error: Failed to upload file to cloud storage [ - 0] trace : 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"

my template event :

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" } );
}});

my template :

<template name="upload_vid">
  <input type="file" name="file" id="file_vid">
  <label for="file_vid">download</label>
</template>

my function to define slingshot (slingshot.js on server side only):

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;
 }
});

and function for use Slingshot and make upload (work fine with image) :

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;

anyone have a solution? thank you beforehand.

David Maw
  • 56
  • 7
  • it works actually , I just did not wait long enough to see the result of the transfer , I refreshed the page before the end of the transfer – David Maw Dec 28 '15 at 13:45

0 Answers0