curl-and-python

READFUNCTION callback not called when using FORM_FILE

From: Teriblus via curl-and-python <curl-and-python_at_cool.haxx.se>
Date: Tue, 23 Feb 2016 10:11:03 +0100

Hi,

I'm sending a file using HTTPPOST and FORM_FILE and I'd like to register to
the READFUNCTION callback in order to abort the transfer in certain cases
(low network coverage).

Here is a sample of my code:

self.curl.setopt(pycurl.URL, url)
self.curl.setopt(pycurl.MAX_SEND_SPEED_LARGE, int(upload_rate))
self.curl.setopt(pycurl.HTTPPOST, [
    ('file', (
        pycurl.FORM_FILE, img_path,
    )),
])
filesize = os.path.getsize(img_path)
self.curl.setopt(pycurl.INFILESIZE, filesize)
self.curl.setopt(pycurl.NOPROGRESS, False)
self.curl.setopt(pycurl.PROGRESSFUNCTION, progress)
self.curl.setopt(pycurl.READFUNCTION, self.FileReader(img_path,
self).read_callback)

self.curl.perform()

The file is correctly sent but the callback is not called.
Note: the callback is called if I send the file with POST, but I need http.

Thanks for your support,
Tristan

_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-python
Received on 2016-02-23