使用上传预设和Meteor.js进行Cloudinary直接上传

时间:2014-07-29 22:32:28

标签: javascript jquery meteor jquery-file-upload cloudinary

所以我可以通过http://cloudinary.com/blog/direct_upload_made_easy_from_browser_or_mobile_app_to_the_cloud#face_detection_based_thumbnail中的基于表单的方法将图像上传到Cloudinary,但是当我尝试增加现有的文件输入时,它会给我进度说文件正在上传,但错误表明该文件不见了。

{"error":{"message":"Missing required parameter - file"}}

js代码是:

Template.fileUpload.created = function () {
    $.cloudinary.config({
      cloud_name: "theCloudName"
    })
  };

  Template.fileUpload.rendered = function () {
    var fileUploadCallback = function(err, result){
      if(err){
        console.log("Error: " + err.reason);
      }else{
        console.log("Success: " + result);
      }
    };

    $('input').unsigned_cloudinary_upload("discussionAdd", {
      cloud_name: 'theCloudName',
      tags: 'discussionAdd'
    }, {
      multiple: true
    }).bind('cloudinarydone', function (e, data) {

        $('.thumbnails').append($.cloudinary.image(data.result.public_id, {
          format: 'jpg',
          width: 150,
          height: 100,
          crop: 'thumb',
          gravity: 'face',
          effect: 'saturation:50'
        }))
      }
    ).bind('cloudinaryprogress', function (e, data) {
      console.log("data loaded is : " + data.loaded + " data size: " + data.total);

      $('.progress_bar').css('width',
        Math.round((data.loaded * 100.0) / data.total) + '%');

    });
  };

和标记是:

<template name="fileUpload">
  <form class='upload_form'>
    upload an image

    <input type="file" class='upload_field cloudinary_fileupload'>
    <div class="progress_bar" style='background-color: red, height: 20px'>
    <div class='thumbnails'></div>
  </div>
  </form>
</template>

1 个答案:

答案 0 :(得分:7)

结果我错过了名字=&#34;文件&#34;输入标记中的属性。