Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does file_write actually work? #88

Closed
TheCrazyT opened this issue Dec 17, 2023 · 3 comments
Closed

Does file_write actually work? #88

TheCrazyT opened this issue Dec 17, 2023 · 3 comments

Comments

@TheCrazyT
Copy link

I mean I tested it myself and it always created a empty file without content.
I see no way that the "fd" gets even passed to the api-endpoint.
Actually it gets removed at:
https://github.com/tomgross/pcloud/blob/master/src/pcloud/api.py#L254

@tomgross
Copy link
Owner

Hi @TheCrazyT please see the documentation on how to upload: https://github.com/tomgross/pcloud/blob/master/README.rst#uploading-files

@TheCrazyT
Copy link
Author

I was more interested in appending data to existing files (so I needed to use "opener.open_fs" with append-flag).
Thats why i was not able to use "uploadfile".

As mentioned before the fd-param does not get set.
Although this is fine with "normal" uploads, it won't work if you use "pcloudfs".
But I got around the bug by patching the code by commands.

Btw:
The commands I used for patching are:

sed -i 's/kwargs.pop("fd", None)/fd=kwargs.pop("fd", None)/' pcloud/api.py
sed -i 's/self.endpoint + method, data=m, headers={"Content-Type": m.content_type}/self.endpoint + method + f"?fd=\{fd\}", data=m, headers=\{"Content-Type": m.content_type\}/' pcloud/api.py

(I'm using those commmands in a jupyter notebook ... therefore was not able to edit the files by hand)
Not shure if fd needs to be a query-parameter or can be a POST-parameter (can't remember if I tried as POST-param and it didn't work)

@tomgross
Copy link
Owner

tomgross commented Mar 1, 2024

Fixed with 1.3 https://pypi.org/project/pcloud/1.3/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants