How to use the downloadfile method?
pscal67 opened this issue · 4 comments
Im able to upload files but i struggle to understand the downloadfile method.
Does anyone have a simple code example for downloading a file?
The purpose of the downloadfile
-method is to retrieve the metadata from a download (share) link. What you want probably is to download file contents, which can be achived by the file ops API (https://docs.pcloud.com/methods/fileops/index.html)
Here is a minimal example:
In [7]: pc.file_open(path='/somefile.txt', flags=api.O_CREAT)
Out[7]: {'result': 0, 'fd': 1, 'fileid': 2046546721}
In [8]: pc.file_size(fd=1)
Out[8]: {'result': 0, 'size': 238, 'offset': 0}
In [9]: pc.file_read(fd=1, count=238)
Out[9]: b'Some Content'
How do you download multiple files? Run the same code in parallel for a list of paths? Or consistently? Is there a function that expects a list of paths or a list of fileid
's?
Code Snippet:
pc = PyCloud('emailid', 'password', endpoint='eapi')
pc.downloadfile(url="File Download Link", path="Local Directory")