I'm trying to test an image upload field with django 1.7, DRF 2.4.3 and Pillow 2.6.1.
File upload is working properly from the admin and when i test using curl
curl -X POST -S -H 'Accept: application/json' -F 'my_image=@hm.jpg;type=image/jpg' http://localhost:8000/api/randomresource/
When i ran a similar test in an APITestCase
temp_file = open('hm.jpg',"r")
response = self.client.post('randomresource', {"my_image":temp_file}, format='multipart')
self.assertEqual(response.status_code,status.HTTP_201_CREATED)
I get
{'my_image': [u'Upload a valid image. The file you uploaded was either not an image or a corrupted image.']}
Appreciate any help with this one. Thanks.