Skip to content

Commit

Permalink
Fix upload with int folderid #63
Browse files Browse the repository at this point in the history
  • Loading branch information
tomgross committed Oct 23, 2022
1 parent 2b21f24 commit 110c114
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Changelog
1.1 (unreleased)
----------------

- Nothing changed yet.
- Fix upload with int folderid #63 [tomgross]


1.0 (2022-02-02)
Expand Down
3 changes: 3 additions & 0 deletions src/pcloud/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,9 @@ def uploadfile(self, **kwargs):
),
)
]
if "folderid" in kwargs:
# cast folderid to string, since API allows this but requests not
kwargs["folderid"] = str(kwargs["folderid"])
return self._upload("uploadfile", files, **kwargs)

@RequiredParameterCheck(("progresshash",))
Expand Down
8 changes: 8 additions & 0 deletions src/pcloud/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ def test_upload_files(self):
"metadata": {"size": 14},
}

def test_upload_files_int_folderid(self):
api = DummyPyCloud("foo", "bar")
testfile = os.path.join(os.path.dirname(__file__), "data", "upload.txt")
assert api.uploadfile(files=[testfile], folderid=0) == {
"result": 0,
"metadata": {"size": 14},
}

def test_extractarchive(self):
api = DummyPyCloud("foo", "bar")
testfile = os.path.join(
Expand Down

0 comments on commit 110c114

Please sign in to comment.