X7ROOT File Manager
Current Path:
/opt/hc_python/share/doc/pycurl/examples/quickstart
opt
/
hc_python
/
share
/
doc
/
pycurl
/
examples
/
quickstart
/
📁
..
📁
__pycache__
📄
file_upload_buffer.py
(311 B)
📄
file_upload_real.py
(291 B)
📄
file_upload_real_fancy.py
(483 B)
📄
follow_redirect.py
(250 B)
📄
form_post.py
(564 B)
📄
get.py
(583 B)
📄
get_python2.py
(447 B)
📄
get_python2_https.py
(498 B)
📄
get_python3.py
(403 B)
📄
get_python3_https.py
(454 B)
📄
put_buffer.py
(472 B)
📄
put_file.py
(300 B)
📄
response_headers.py
(2.05 KB)
📄
response_info.py
(498 B)
📄
write_file.py
(357 B)
Editing: put_buffer.py
#! /usr/bin/env python # -*- coding: utf-8 -*- # vi:ts=4:et import pycurl try: from io import BytesIO except ImportError: from StringIO import StringIO as BytesIO c = pycurl.Curl() c.setopt(c.URL, 'https://httpbin.org/put') c.setopt(c.UPLOAD, 1) data = '{"json":true}' # READDATA requires an IO-like object; a string is not accepted # encode() is necessary for Python 3 buffer = BytesIO(data.encode('utf-8')) c.setopt(c.READDATA, buffer) c.perform() c.close()
Upload File
Create Folder