multipartform-data

FastAPI: form-data name with a dot

FastAPI: form-data name with a dot Question: I have documentation. Form-data names have dots. This code doesn’t work: from fastapi import FastAPI, File, UploadFile app = FastAPI() @app.post(‘/test’) async def test(anpr: UploadFile = File(…), licensePlatePicture: UploadFile = File(…), detectionPicture: UploadFile = File(…) ): ””” return None Question: What if we have form-data name with a …

Total answers: 1

How to create a FastAPI endpoint that can accept either Form or JSON body?

How to create a FastAPI endpoint that can accept either Form or JSON body? Question: I would like to create an endpoint in FastAPI that might receive (multipart) Form data or JSON body. Is there a way I can make such an endpoint accept either, or detect which type of data is receiving? Asked By: …

Total answers: 1

Send in-memory bytes (file) over multipart/form-data POST request. Python

Send in-memory bytes (file) over multipart/form-data POST request. Python Question: ;TLDR I want to send a file with requests.send() using multipart/form-data request without storing the file on a hard drive. Basically, I’m looking for an alternative for open() function for bytes object Hello, I’m currently trying to send multipart/form-data request and pass in-memory files in …

Total answers: 1

Can't open and read content of an uploaded zip file with FastAPI

Can't open and read content of an uploaded zip file with FastAPI Question: I am currently developing a little backend project for myself with the Python Framework FastAPI. I made an endpoint, where the user should be able to upload 2 files, while the first one is a zip-file (which contains X .xmls) and the …

Total answers: 3

Send attached file with Mailgun using python

Send attached file with Mailgun using python Question: I’m trying to send an email with an attached file with the Mailgun API using requests.post. In their documentation they alert that you must use multipart/form-data encoding when sending attachments, I’m trying this: import requests MAILGUN_URL = ‘https://api.mailgun.net/v3/sandbox4f…’ MAILGUN_KEY = ‘key-f16f497…’ def mailgun(file_url): “””Send an email using …

Total answers: 1

How to send JSON as part of multipart POST-request

How to send JSON as part of multipart POST-request Question: I have following POST-request form (simplified): POST /target_page HTTP/1.1 Host: server_IP:8080 Content-Type: multipart/form-data; boundary=AaaBbbCcc –AaaBbbCcc Content-Disposition: form-data; name=”json” Content-Type: application/json { “param_1”: “value_1”, “param_2”: “value_2″} –AaaBbbCcc Content-Disposition: form-data; name=”file”; filename=”…” Content-Type: application/octet-stream <..file data..> –AaaBbbCcc– I try to send POST-request with requests: import requests import …

Total answers: 3

multipart data POST using python requests: no multipart boundary was found

multipart data POST using python requests: no multipart boundary was found Question: I have a form-data as well as file to be sent in the same POST. For ex, {duration: 2000, file: test.wav}. I saw the many threads here on multipart/form-data posting using python requests. They were useful, especially this one. My sample request is …

Total answers: 3

Using MultipartPostHandler to POST form-data with Python

Using MultipartPostHandler to POST form-data with Python Question: Problem: When POSTing data with Python’s urllib2, all data is URL encoded and sent as Content-Type: application/x-www-form-urlencoded. When uploading files, the Content-Type should instead be set to multipart/form-data and the contents be MIME-encoded. To get around this limitation some sharp coders created a library called MultipartPostHandler which …

Total answers: 6