Can you send me for one I need to do for one file
On Mon, Oct 19, 2020 at 11:36 AM Muhammad Imran <[email protected]>
wrote:
> Can you post serialize class and view here for upload images please I need
> to do that stuff big thanks.
>
> On Tuesday, July 16, 2019 at 2:20:49 PM UTC+5 Tobias wrote:
>
>> Found the solution by myself: Just add a list of files to the files block.
>>
>> from django.core.files.base import ContentFile
>> from rest_framework.test import APIClient
>>
>> data = dict()
>> data['files'] = [
>> ContentFile(content='contentabc', name='filenameA.txt'),
>> ContentFile(content='contentxyz', name='filenameB.txt')
>> ]
>>
>> client = APIClient()
>> client.post('/testurl/', data=data, format='multipart')
>>
>>
>>
>>
>> Am Mittwoch, 5. Dezember 2018 13:00:49 UTC+1 schrieb Tobias:
>>>
>>> Hello,
>>>
>>> our api requires to upload multiple files on the same fieldname:
>>>
>>> Content-Type:
>>> multipart/form-data;boundary=------FormBoundaryShouldDifferAtRuntime
>>>
>>> ------FormBoundaryShouldDifferAtRuntime
>>> Content-Disposition: form-data; name="*files*"; filename="
>>> *filenameA.pdf*"
>>> Content-Type: application/pdf
>>>
>>> [content]
>>> ------FormBoundaryShouldDifferAtRuntime
>>> Content-Disposition: form-data; name="*files*"; filename="
>>> *filenameB.pdf*"
>>> Content-Type: application/pdf
>>>
>>> [content]
>>> ------FormBoundaryShouldDifferAtRuntime--
>>>
>>> At the moment i am not able to write a test with two files on the same
>>> files key. MultiValueDict does not work with APIClient.post(). Any
>>> recommendations?
>>>
>> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django REST framework" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/django-rest-framework/oT-3cJ8_bSE/unsubscribe
> .
> To unsubscribe from this group and all its topics, send an email to
> [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-rest-framework/b97d5181-0801-445d-911f-36b210eb58f5n%40googlegroups.com
> <https://groups.google.com/d/msgid/django-rest-framework/b97d5181-0801-445d-911f-36b210eb58f5n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
--
You received this message because you are subscribed to the Google Groups
"Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-rest-framework/CAKKYPx4B-LQ33qU28cNC9KL_WKGQ6ywXQ8PoTvVUoQd%2B%3DZ%3DebA%40mail.gmail.com.