0

I have searched stackoverflow for this question but they all seem similar (not actually the same issue) while some have the exact opposite problem.

Here is my code:

    Cloudinary.upload(file, {
        folder: "images",
        type: "private"
        }, (err, res) => {
            if(err) {
                console.log("Upload Error: ", err);
                alert("Sorry, there was an error uploading the image");
                return;
            }

            if (res) {
                console.log("Upload Result: ", res);
            }

        });

the above code works with safari and chrome but fails on firefox. Its driving me insane!

Firefox throws an error saying:

File.lastModifiedDate is deprecated. Use File.lastModified instead.
SyntaxError: JSON.parse: unexpected end of data at line 1 column 1 of the JSON data[Learn More]  lepozepo_cloudinary.js:224:20
Cloudinary._upload_file/</<

Not sure what the issue here is, Any help is apprecieated. Thanks.

Ally Jr
  • 1,055
  • 1
  • 14
  • 27

1 Answers1

0

try this approach. In the Cloudinary admin "settings" under "upload". Choose between sign or unsigned

Client

$.cloudinary.config({
    cloud_name: 'your-cloud-name',
    api_key: '1234xxxxxxxxxx'
});

let files = event.currentTarget.your_form_field_name.files;

 return Cloudinary.upload(files, {

 }, function(err, res) {
           if (err) {
              console.error(err);
           } else {          
              /** Do something with the response **/  
 });

Server

//cloudinary
Cloudinary.config({
    cloud_name: 'your-cloud-name',
    api_key: '1234xxxxxxxx',
    api_secret: '5678xxxxxxxx'
});

Cloudinary.rules.signature = function() {
    return this.userId;
};

Note you may not need the signature if you are doing unsigned requests

NicholasByDesign
  • 781
  • 1
  • 11
  • 33
  • Hey, thanks for responding, I tried the approach and still getting the error on firefox. Are you using the lepozepo:cloudinary plugin? – Ally Jr Jan 31 '17 at 16:57
  • 1
    Oh yea, looks like Moziila is doing away with that part of the API. Lepozepo will have to update his package most likely. – NicholasByDesign Jan 31 '17 at 17:02
  • Modify the package, or wait for lepozepo to make a patch. I use this package for a lot of things so I feel your pain. – NicholasByDesign Jan 31 '17 at 17:19
  • This also maybe helpful as it is directly from Cloudinary [https://github.com/cloudinary/cloudinary_npm](https://github.com/cloudinary/cloudinary_npm) – NicholasByDesign Jan 31 '17 at 17:45