Lepozepo / cloudinary

MIT License
94 stars 42 forks source link

c_upload_stream seems to work with only small files #29

Closed arathipanya closed 9 years ago

arathipanya commented 9 years ago

Hi, I am using #c_upload_stream to upload some pictures on Cloudinary, with also _cloudinary.after.update

In local everything works fine but once in production, when I upload a file > 900ko nothing happens...

Here is my code

//In template html imageForm
{{#c_upload_stream callback="save_url"}}
<input type="file" accept="image/*;capture=camera">

<div id="p-image-loading" style="display:none;">
  Uploading...
</div>
{{/c_upload_stream}}
//In front js
Template.imageForm.events({
    "change input[type='file']": function(e) {
        var files = $("input")[0].files;

        C.upload_stream(files, function(res) {
            console.log("RES", res);
        });
    }
})

_cloudinary.after.update(function(user,file){
    if(file.percent_uploaded === 100 && !file.uploading){
        $('#p-image-loading').hide();
        Session.set("image-uploading", false);
        console.log("getting image...");
        var _img = $.cloudinary.image(file.public_id, {
            transformation: [{width: 150, height: 170, crop: "fill"}]
        });
        $('#p-image-upload').html(_img[0].outerHTML+'');
    } else {
        console.log("loading....");
        $('#p-image-upload').html('');
        $('#p-image-loading').show();
        Session.set("image-uploading", true);
    }
})

I get neither some errors nor console logs...

I hope it is clear :s ! Thanks,

Lepozepo commented 9 years ago

Upgrade to the latest version, we are not using streams anymore.

Marcelo Reyna

On Wed, Jul 22, 2015 at 12:05 PM, arathipanya notifications@github.com wrote:

Hi, I am using #c_upload_stream to upload some pictures on Cloudinary, with also _cloudinary.after.update In local everything works fine but once in production, when I upload a file > 900ko nothing happens... Here is my code

//In template html imageForm
{{#c_upload_stream callback="save_url"}}
<input type="file" accept="image/*;capture=camera">
<div id="p-image-loading" style="display:none;">
Uploading...
</div>
{{/c_upload_stream}}
//In front js
Template.imageForm.events({
    "change input[type='file']": function(e) {
        var files = $("input")[0].files;
        C.upload_stream(files, function(res) {
            console.log("RES", res);
        });
    }
})
_cloudinary.after.update(function(user,file){
    if(file.percent_uploaded === 100 && !file.uploading){
        $('#p-image-loading').hide();
        Session.set("image-uploading", false);
        console.log("getting image...");
        var _img = $.cloudinary.image(file.public_id, {
          transformation: [{width: 150, height: 170, crop: "fill"}]
        });
        $('#p-image-upload').html(_img[0].outerHTML+'');
    } else {
        console.log("loading....");
      $('#p-image-upload').html('');
      $('#p-image-loading').show();
      Session.set("image-uploading", true);
    }
})

I get neither some errors nor console logs... I hope it is clear :s !

Thanks,

Reply to this email directly or view it on GitHub: https://github.com/Lepozepo/cloudinary/issues/29

arathipanya commented 9 years ago

Oh, good to know :) My bad, thank you

Lepozepo commented 9 years ago

No problem :D

Marcelo Reyna

On Wed, Jul 22, 2015 at 12:08 PM, arathipanya notifications@github.com wrote:

Oh, good to know :)

My bad, thank you

Reply to this email directly or view it on GitHub: https://github.com/Lepozepo/cloudinary/issues/29#issuecomment-123829711

arathipanya commented 9 years ago

It works perfectly. Here is my version :

Template.imageForm.events({
    "change input[type='file']": function(e) {
        var files = e.target.files;
        //show an uploading message...
        Session.set("image-uploading", true);
        Cloudinary.upload(files, {}, function(err, res) {
            //hide uploading message...
            Session.set("image-uploading", false);
            var _img = $.cloudinary.image(res.public_id, {
                transformation: [{width: 150, height: 170, crop: "fill"}]
            });
            //append uploaded image _img
        });
    }
})