real path should not be used when creating distination file list.
This commit is contained in:
@ -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.")
|
||||
|
Reference in New Issue
Block a user