Client

class upyun.UpYun(bucket, auth, stype, api_host=4, domain=None, ssl=False)

Feature complete UpYun REST client

Parameters:
  • bucket (str) – Your bucket
  • auth(username, passwd) pair or any object derived from requests.auth.AuthBase
  • stype – The space type, SPACE_TYPE_FILE or SPACE_TYPE_IMAGE
  • api_host – API host to use, see API Hosts
  • domain (str) – Your custom domain
  • ssl (bool) – Whether to use SSL

Usage:

client = UpYun('test', ('user', 'pass'), const.SPACE_TYPE_FILE)
client.put('/test.txt', open('/tmp/test.txt'))
_digest(data)
_get_data(fileo)
_get_file_url(path)
_get_url(path)
_prepare_put_request(path, fileo, mkdir, mimetype, secret, verify, headers=None)

Prepaer the put request

_prepare_session(auth, ssl)
api_host
delete(path)

Delete a file or an empty folder

Parameters:path – Path of the file or folder to delete
Return type:Response
get(path)

Get a file

Parameters:path – Path of the file to retrieve
Return type:GetResponse
info(path)

Retrieve file info

Return type:InfoResponse
ls(path)

List contents of a folder

Parameters:path – Path to the folder
Return type:LsResponse
mkdir(path, mk_parent=True)

Create a folder on server

Parameters:
  • path – Folder path
  • mk_parent – Whether to create the parent folder if not existed
Return type:

Response

put(path, fileo, mkdir=True, mimetype=None, secret=None, verify=True, headers=None)

Put an file onto the server

Parameters:
  • path – File path on the server
  • fileo – File like object of the file to upload
  • mkdir – Whether to make the parent folder if not existed
  • mimetype – Mime-type of the file, used by server to determine the extension of the file
  • secret – Secret for user to later access the file uploaded
  • verify – Whether to verify the file integrity using md5 hashing
  • headers – Additional headers
Return type:

Response or PutImageResponse

put_thumbnail(path, fileo, version=None, ttype=None, res=None, quality=None, sharpen=None, **kwargs)

Put an image as a thumbnail on the server, the original image will not be uploaded

Parameters:
  • path – Thumbnail path on the server
  • fileo – File like object of the image
  • version – Predefined thumbnail version name
  • ttype – Thumbnail type, see THUMB_TYPES
  • res (tuple) – Image resolution, format: (width, height)
  • quality – Image quality, default: 90
  • sharpen (bool) – Whether to sharpen the image
Return type:

PutImageResponse

session = None

The requests.Session object to use for the API requests

stype
usage()

Retrieve the space usage info

Return type:UsageResponse
Read the Docs v: latest
Versions
latest
Downloads
PDF
HTML
Epub
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.