I decided to process the image being uploaded to get the GPS location in views.
the code work and saves to the db but I get prompted to with a FileNotFoundError at /api/v1/addWaste/ [Errno 2] No such file or directory: '/tmp/tmpnsym9i2b.upload.jpg'
error.
I learnt that this is because my upload is larger than 2.5mb.
It is more complicated because the data ends up getting saved in the db.
here is snippet of my views code I am using Django Rest Frameworks Generic Create View
def create(self, request, *args, **kwargs):
serializer = self.get_serializer(data=request.data)
# file = request.FILES['files']
serializer.is_valid(raise_exception=True)
# geospatial fields
picture=(serializer.validated_data['field_picture'])
print(picture.temporary_file_path())
latitude, longitude = get_coordinates(picture)
serializer.validated_data['latitude']= latitude
serializer.validated_data['longitude'] = longitude
# geom
serializer.validated_data['geom'] = Point(latitude,longitude)
serializer.save()
if serializer.save():
return Response({
'Response': 'Waste point Created suceesfully',
'payload': serializer.data
})
```
Here is a copy of my terminal debug message
/.local/share/virtualenvs/Backend-bhMgLIsh/lib/python3.8/site-packages/django/core/files/move.py", line 56, in file_move_safe with open(old_file_name, 'rb') as old_file: FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpnsym9i2b.upload.jpg' [02/Jun/2021 11:24:51] "POST /api/v1/addWaste/ HTTP/1.1" 500 179179
Thank you for your help.