Skip to content

What is the correct format for uploading images via /api/recipes/{slug}/image Update Recipe Image API call #4788

Answered by Christian-Me
Christian-Me asked this question in Q&A
Discussion options

You must be logged in to vote

Thank you for your fast answer and sorry for bothering you with JavaScript but this is the only language, except C++, i'm familiar with.

to make a long (4h) story short - after a lot of digging as this is my first time dealing with http APIs - here is the solution

        import FormData from 'form-data';

        const formData = new FormData();
        formData.append('image',Buffer.from(mpRecipe.Image, 'base64'), {
            filename: 'image.jpg',
            contentType: 'image/jpeg',
          });
        formData.append('extension','jpg')
        
        response = await axios.put(BASE_URL+'/api/recipes/'+currentSlug+'/image', formData, {
            headers: {
                ...f…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@michael-genson
Comment options

Answer selected by Christian-Me
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants