Skip to content

Instantly share code, notes, and snippets.

@DataGreed
Created April 18, 2019 12:31
Show Gist options
  • Select an option

  • Save DataGreed/c893fecac5b18bb5f801cf63580234ce to your computer and use it in GitHub Desktop.

Select an option

Save DataGreed/c893fecac5b18bb5f801cf63580234ce to your computer and use it in GitHub Desktop.
Locust.io post file
from locust import TaskSet, task
class UserBehaviour(TaskSet):
@task
def someTask(self):
filename="some/file.jpg"
with open(filename, 'rb') as img:
self.client.post(
"/some/url",
data={
"someOtherData": "foo",
},
files={
"profile[photo]": (
'default.jpg',
img,
'image/jpeg'
)
}
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment