| 1 | def test_big_base64_upload(self):
|
|---|
| 2 | test_string = open('/dev/urandom', 'r').read(524288)
|
|---|
| 3 | payload = "\r\n".join([
|
|---|
| 4 | '--' + client.BOUNDARY,
|
|---|
| 5 | 'Content-Disposition: form-data; name="file"; filename="test.txt"',
|
|---|
| 6 | 'Content-Type: application/octet-stream',
|
|---|
| 7 | 'Content-Transfer-Encoding: base64',
|
|---|
| 8 | '',
|
|---|
| 9 | base64.b64encode(force_bytes(test_string)).decode('ascii'),
|
|---|
| 10 | '--' + client.BOUNDARY + '--',
|
|---|
| 11 | '',
|
|---|
| 12 | ]).encode('utf-8')
|
|---|
| 13 | r = {
|
|---|
| 14 | 'CONTENT_LENGTH': len(payload),
|
|---|
| 15 | 'CONTENT_TYPE': client.MULTIPART_CONTENT,
|
|---|
| 16 | 'PATH_INFO': "/file_uploads/echo_content/",
|
|---|
| 17 | 'REQUEST_METHOD': 'POST',
|
|---|
| 18 | 'wsgi.input': client.FakePayload(payload),
|
|---|
| 19 | }
|
|---|
| 20 | response = self.client.request(**r)
|
|---|
| 21 | received = json.loads(response.content.decode('utf-8'))
|
|---|
| 22 |
|
|---|
| 23 | self.assertEqual(received['file'], test_string)
|
|---|