[Python] upload file using PycURL
PycURL is a Python interface to libcurl, the multiprotocol file transfer library. Similarly to the urllib Python module, PycURL can be used to fetch objects identified by a URL from a Python program. Beyond simple fetches however PycURL exposes most of the functionality of libcurl, including:
- Speed – libcurl is very fast and PycURL, being a thin wrapper above libcurl, is very fast as well. PycURL was benchmarkedto be several times faster than requests.
- Features including multiple protocol support, SSL, authentication and proxy options. PycURL supports most of libcurl’s callbacks.
- Multi and share interfaces.
- Sockets used for network operations, permitting integration of PycURL into the application’s I/O loop (e.g., using Tornado).
- Python 2.6, 2.7 or 3.1 through 3.6.
- libcurl 7.19.0 or better.
Download source and binary distributions from PyPI or Bintray. Binary wheels are now available for 32 and 64 bit Windows versions.
The above code is written in a library with pycurl http request to call a generic function.
upload_file is a dict type requires two key, file_path (specify the file path to upload) and file_name (file name specified after the upload).
ch.FORM_FILE : Specifies the path to the file you want to upload
ch.FORM_FILENAME : Specifies the name of the file you want to upload