python script to handle uploaded file via http post
Question: I am working on a django project where i try to upload a file via http post
request.

my upload script is :

    
    
    url=r'http://MYSITEURL:8000/upload'
    files={'file':open('1.png','rb')}
    r=requests.post(url,files=files)
    

my receiving side is in my django site , in views.py:

    
    
    def upload_image(request):
    from py_utils import open_py_shell;open_py_shell.open_py_shell()
    

when i do request.FILES i can see all the post details, what i want to know is
how to save it in the server side once i got the post request


Answer: What you have in `request.FILES` is `InMemoryUploadedFile`. You just need to
save it somewhere in file system.

This is example method taken from [Django
docs](https://docs.djangoproject.com/en/1.7/topics/http/file-uploads/):

    
    
    def handle_uploaded_file(f):
        with open('some/file/name.txt', 'wb+') as destination:
            for chunk in f.chunks():
                destination.write(chunk)
    

