Uploading image from a base64 string

Comments

6 comments

  • Avatar
    Roee Ben Ari

    Hi Asi, 

    Can you please open a support ticket via support@cloudinary.com and share the code responsible for the error alongside an example file that fails so we can further investigate the issue?

    Thanks!

    0
    Comment actions Permalink
  • Avatar
    miguel

    Same problem

    0
    Comment actions Permalink
  • Avatar
    Asi Oren

    Hey Miguel,

    My problem was solved
    Can't remember exactly what solved it for me but here is the upload code from the server:

    app.post(`/${url}`, function (req, res) {
     
        var dataURI = req.body.dataURI;
        var uploadStr = 'data:image/jpeg;base64,' + dataURI;

        cloudinary.v2.uploader.upload(uploadStr, {
            overwrite: true,
            invalidate: true,
            width: 810, height: 456, crop: "fill"
        },
            function (error, result) {
                res.json(result);
            });
    });
     
    Hope it help
    Asi
    1
    Comment actions Permalink
  • Avatar
    Luka

    Hi,

    The problem has taken place because you shouldn't place spaces into your

    data:image/jpeg;base64,[your_string] string.

    At least it solved the problem for me :)

    Hope it helps someone.

    (i wrote this for someone who would have the same problem in the future)

    1
    Comment actions Permalink
  • Avatar
    valentin

    Buenos dias, 

    Estoy teniendo el mismo problemas y no puedo encontrar la solucion realmente. 

    const uploaded = await cloudinary.uploader.upload(image, {
                    upload_preset: 'winesImg'
                })
    ese seria el upload para subir la imagen a cloudinary, la propiedad image me llega por body la cual si la paso asi me tira el error de ENAMETOOLONG, en cambio, probe haciendo un console.log a lo que me llega y pegandolo en lugar de poner la image y si se carga en cloudinary. no puedo entender por que el error, estaria muy agradecido si puedieran ayudarme.
    ---

    Good morning, 

    I am having the same problem and can't really find the solution. 

    const uploaded = await cloudinary.uploader.upload(image, {
                    upload_preset: 'winesImg'
                })

    that would be the upload to upload the image to cloudinary, the image property arrives to me by body which if I pass it this way I get the error of ENAMETOOLONG, instead, try making a console.log to what I get and pasting it instead of putting the image and if it loads in cloudinary. I can not understand why the error, I would be very grateful if you could help me.

    0
    Comment actions Permalink
  • Avatar
    Eric Pasos

    Hi Valentine,

    Can you please help to open a support ticket here (https://support.cloudinary.com/hc/en-us/requests/new) and to provide us with image information and your cloud name so we can investigate the issue?

    Thanks in advance.

    0
    Comment actions Permalink

Please sign in to leave a comment.