PricingBlog

API body for multipart/form-data

  • kamilnader-1198209607227682946

    Kamil

    2 years ago

    Hello, how would the body formula look like for multipart/form-data header. I want to sent the file from input type file that is saved in variable file.
    -H 'Content-Type: multipart/form-data; charset=utf-8' \
    -F "file="

    Is it possible? or for now only object (JSON)

    Thank you.
  • andreasmoller-1198212443747389490

    Andreas Møller

    2 years ago

  • kamilnader-1198214350595432528

    Kamil

    2 years ago

    Thank you. This seems to be related to the supabase API. While I have the same formula for saving a file to a variable, the API is different. I need to somehow recreate this:
    1198214350264094782-Image_2024-01-20_at_11.11.21_AM.jpeg
  • Tod-1198214352751312917

    Tod

    2 years ago

    Great energy @Kamil! Your continuous contribution to the toddle Community just made you advance to Community Level 3!
  • andreasmoller-1198215197433798737

    Andreas Møller

    2 years ago

    Thats seems to be very similar to how supabase does file upload
  • Erik covers the multipart file upload In the second half of the video
  • kamilnader-1198233266994556958

    Kamil

    2 years ago

    With supabase you need 2 API's for storing data to database, while I only have one. And there is no JSON in body in my case. Is it ok if I sent you my API?
  • andreasmoller-1198265445304774746

    Andreas Møller

    2 years ago

    Supabase makes two request because you need to request an upload URL, if your api does not need that you can just skip it.

    The second request is the multipart form request, That is set with the Content-Type header.
  • You are welcome to send me the API.
  • The second request is not a JSON request, when you change the Content-type header toddle will encode it as multipart form data.
  • kamilnader-1198267797491417108

    Kamil

    2 years ago

    Thank you Andreas, I did all that and it's good that toddle will encode it as multipart form data, still it don't seems to work in my case. I'm gonna sent you DM.
  • andreasmoller-1198267871822880768

    Andreas Møller

    2 years ago

    👍
  • kamilnader-1199679357887709316

    Kamil

    2 years ago

    @Andreas Møller Can you please check my message. I still can't get this API request to work.