Created
August 2, 2016 15:00
-
-
Save rverton/f1542b2c1d7cf0e67e25f4588586bfcf to your computer and use it in GitHub Desktop.
Test file upload with flask (Python3)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from io import BytesIO | |
def test_file_upload(client): | |
data = { | |
'field': 'value', | |
'file': (BytesIO(b'FILE CONTENT'), 'test.csv') | |
} | |
rv = client.post('/upload', buffered=True, | |
content_type='multipart/form-data', | |
data=data) | |
assert rv.status_code == 200 |
Those are both POST data fields, one with the name "field" and one with the name "file" as an example.
Upon POSTing, I'm getting an error DebugFilesKeyError for which I'm using an exception. Any suggestions on fixing it?
No sorry, I think you better ask in #pocoo@freenode.
Am Di, 11. Jun 2019, um 14:49, schrieb PVinay737:
… Upon POSTing, I'm getting an error DebugFilesKeyError for which I'm using an exception. Any suggestions on fixing it?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub <https://gist.github.com/f1542b2c1d7cf0e67e25f4588586bfcf?email_source=notifications&email_token=AALP2GNPTIXJ4MSRXPF6A4LPZ6NOTA5CNFSM4HWVVOU2YY3PNVWWK3TUL52HS4DFVNDWS43UINXW23LFNZ2KUY3PNVWWK3TUL5UWJTQAFTPLU#gistcomment-2940602>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AALP2GIWRNCSOKINHHVNAH3PZ6NOTANCNFSM4HWVVOUQ>.
--
.web https://robinverton.de
.tel +49 170 183 7898
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What should 'field' and 'file' do ?