tomgross/pcloud

How to use the downloadfile method?

Closed 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'
qo4on commented

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?

Can someone help me download a file from Pcloud to my local directory? I have attached the code snippet. Please help ASAP. I have attached the screenshot.
Uploading 2022-11-10_184949.jpg…

Code Snippet:

pc = PyCloud('emailid', 'password', endpoint='eapi')

pc.downloadfile(url="File Download Link", path="Local Directory")