I'm using Locust.io to load test a python/django website that accepts image upload::
headers = {'content-type': 'multipart/form-data'}
image = open('img.jpg', 'rb')
payload = {'id': self.id}
files = {'photo': image}
upload_result = self.client.post("/image/", data=payload, files=files, headers=headers)
When I use the above I see request.FILES
in Django is None
. However when I use POSTMAN instead of Locust to do the same thing, I get the files object in request
in Django.
server.py
photo = request.FILES.get('photo')
id = request.POST.get('id')
form = PhotosModelForm(request.POST, request.FILES)
How do I send the file in the Locust HTTP client request along with some POST data?