项目作者: ricohapi

项目描述 :
高级语言: Python
项目地址: git://github.com/ricohapi/media-storage-py.git
创建时间: 2016-05-31T06:41:33Z
项目社区:https://github.com/ricohapi/media-storage-py

开源协议:MIT License

下载


Ricoh Media Storage for Python

Media Storage Python Library for Ricoh API.

Requirements

You need

  • Ricoh API Client Credentials (client_id & client_secret)
  • Ricoh ID (user_id & password)

If you don’t have them, please register yourself and your client from THETA Developers Website.

Install

Befor install, you must install auth-py

  1. $ pip install --upgrade git+https://github.com/ricohapi/media-storage-py.git

Uploading a JPEG file

  1. from ricohapi.mstorage.client import MediaStorage
  2. from ricohapi.auth.client import AuthClient
  3. aclient = AuthClient('<your_client_id>', '<your_client_secret>')
  4. aclient.set_resource_owner_creds('<your_user_id>', '<your_password>')
  5. mstorage = MediaStorage(aclient)
  6. mstorage.connect()
  7. print(mstorage.upload('./upload_file_path.jpg'))

SDK API

AuthClient

  1. aclient = AuthClient('<your_client_id>', '<your_client_secret>')
  2. aclient.set_resource_owner_creds('<your_user_id>', '<your_password>')

Constructor

  1. mstorage = MediaStorage(<AuthClient object>)

Connect to the server

  1. mstorage.connect()

Upload a file

  1. mstorage.upload('./upload_file_path.jpg')

Download a file

  1. mstorage.download_to('<media_id>', './download_file_path.jpg')

Download a file as bytes object

  1. mstorage.download('<media_id>')

List media ids

  1. mstorage.list()
  2. mstorage.list({'limit': 25, 'after': '<cursor-id>'})

Delete a file

  1. mstorage.delete('<media_id>')

Get information of a file

  1. mstorage.info('<media_id>')

Get all metadata of a file

  1. mstorage.meta('<media_id>')

Get specific metadata of a file

  1. mstorage.meta('<media_id>', 'user')
  2. mstorage.meta('<media_id>', 'user.<key>')
  3. mstorage.meta('<media_id>', 'exif')
  4. mstorage.meta('<media_id>', 'gpano')

Add user metadata to a file

Existing metadata value for the same key will be overwritten.
Up to 10 user metadata can be attached to a media data.

  1. mstorage.add_meta('<media_id>', { 'user.<key1>' : '<value1>', 'user.<key2>' : '<value2>', ...})

Remove user metadata from a file

  1. mstorage.remove_meta('<media_id>', 'user.<key>')

Remove all user metadata from a file

  1. mstorage.remove_meta('<media_id>', 'user')

Search media ids by user metadata

return media ids which have all key value pairs

  1. mstorage.list({'limit': 25, 'after': '<cursor-id>', 'filter': { 'meta.user.<key1>' : '<value1>', 'meta.user.<key2>' : '<value2>', ...}})