fixed bug to resolve local files for recursive file upload.

This commit is contained in:
2023-12-20 19:42:06 +09:00
parent 219858e0b6
commit ce0a608db2
5 changed files with 9 additions and 8 deletions

View File

@ -32,7 +32,7 @@ class FilesApi(BaseApi):
token_check(self.connection)
data: dict[str, str | int] = {"folder_id": folder_id}
try:
with open(os.path.relpath(path), mode="rb") as fp:
with open(os.path.realpath(path), mode="rb") as fp:
response = self.connection.post(url, data=data, files={"file": fp})
self._raise_response_error(response)
ret = TypeAdapter(FilesApiCreateResponse).validate_python(response.json())
@ -47,7 +47,7 @@ class FilesApi(BaseApi):
if path is not None:
# update file body
try:
with open(os.path.relpath(path), mode="rb") as fp:
with open(os.path.realpath(path), mode="rb") as fp:
response = self.connection.put(url, files={"file": fp})
except OSError:
raise UnexpectedException(f"Could not open `{path}` file.")