Search code examples
pythonhttppostfile-uploadpys60

How to upload huge files from Nokia 95 to webserver?


I'm trying to upload a huge file from my Nokia N95 mobile to my webserver using Pys60 python code. However the code crashes because I'm trying to load the file into memory and trying to post to a HTTP url. Any idea how to upload huge files > 120 MB to webserver using Pys60.

Following is the code I use to send the HTTP request.

    f = open(soundpath + audio_filename)
    fields = [('timestamp', str(audio_start_time)), ('test_id', str(test_id)), ('tester_name', tester_name), ('sensor_position', str(sensor_position)), ('sensor', 'audio') ]
    files = [('data', audio_filename, f.read())]
    post_multipart(MOBILE_CONTEXT_HOST, MOBILE_CONTEXT_SERVER_PORT, '/MobileContext/AudioServlet', fields, files)
    f.close

Solution

  • where does this post_multipart() function comes from ?

    if it is from here, then it should be easy to adapt the code so that it takes a file object in argument and not the full content of the file, so that post_mutipart reads small chunks of data while posting instead of loading the whole file in memory before posting.

    this is definitely possible.