real path should not be used when creating distination file list.

This commit is contained in:
2023-12-18 16:23:46 +09:00
parent 292ca1df27
commit 9284346153
2 changed files with 5 additions and 5 deletions

View File

@ -1,3 +1,4 @@
import os
from typing import Any, Final
from pydantic import TypeAdapter
@ -31,7 +32,7 @@ class FilesApi(BaseApi):
token_check(self.connection)
data: dict[str, str | int] = {"folder_id": folder_id}
try:
with open(path, mode="rb") as fp:
with open(os.path.relpath(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())
@ -46,7 +47,7 @@ class FilesApi(BaseApi):
if path is not None:
# update file body
try:
with open(path, mode="rb") as fp:
with open(os.path.relpath(path), mode="rb") as fp:
response = self.connection.put(url, files={"file": fp})
except OSError:
raise UnexpectedException(f"Could not open `{path}` file.")