This Python (Version >= 3.6 only!) library provides a Python API to the pCloud storage.
- Can be used as a library
- Comes with a command line script
- Provides a PyFileSystem implementation
Usage of API
>>> from pcloud import PyCloud >>> pc = PyCloud('[email protected]', 'SecretPassword') >>> pc.listfolder(folderid=0)
Uploading files
- from filenames:
>>> pc.uploadfile(files=['/full/path/to/image1.jpg', '/Users/tom/another/image.png'], ... path='/path-to-pcloud-dir')
- from data:
>>> import io >>> from PIL import Image >>> img = Image.open('image.jpg', 'r') >>> bio = io.BytesIO() >>> img.save(bio, format='jpeg') >>> pc.uploadfile(data=bio.getvalue(), filename="image.jpg", path='/path-to-pcloud-dir')
Usage of PyFilesystem with opener
>>> from fs import opener >>> opener.open_fs('pcloud://email%40example.com:SecretPassword@/') <pCloudFS>
Copying files from Linux to pCloud using PyFilesystem
>>> from fs import opener, copy >>> with opener.open_fs('pcloud://email%40example.com:SecretPassword@/') as pcloud_fs: >>> with opener.open_fs('/opt/data_to_copy') as linux_fs: >>> copy.copy_file(src_fs=linux_fs, >>> src_path='database.sqlite3', >>> dst_fs=pcloud_fs, >>> dst_path='/backup/server/database.sqlite3')
Copy directory from Linux to pCloud using PyFilesystem
>>> from fs import opener, copy >>> with opener.open_fs('pcloud://email%40example.com:SecretPassword@/') as pcloud_fs: >>> with opener.open_fs('/opt/data_to_copy') as linux_fs: >>> copy.copy_dir(src_fs=linux_fs, >>> src_path='database/', >>> dst_fs=pcloud_fs, >>> dst_path='/backup/database/')
Implements the pCloud API found at https://docs.pcloud.com/
$ pip install pcloud
- Issue Tracker: https:/tomgross/pycloud/issues
- Source Code: https:/tomgross/pycloud
The project is licensed under MIT (see docs/LICENSE.rst).