[help] the uploaded file is processed for the first time; the file uploaded by diydjango is in the wrong format.

Files uploaded through django are always in the wrong format. The picture cannot be opened
class FileUploadView (APIView):

parser_classes = (FileUploadParser,)

def post(self, request, filename, format=None):
    print filename
    file_obj = request.data["file"]
    file_dest = join(MEDIA_ROOT,"pic",filename)
    print file_obj.multiple_chunks()
    with open(file_dest,"w") as f:
        for chunk in file_obj.chunks():
            f.write(chunk)
    -sharp ...
    -sharp do some stuff with uploaded file
    -sharp ...
    return Response(status=204)
    

the original content is in the red box,
clipboard.png


:

clipboard.png

Menu