diff --git a/.idea/misc.xml b/.idea/misc.xml
index a831f4d..55d1cea 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -3,5 +3,5 @@
-
+
\ No newline at end of file
diff --git a/docs/conf.py b/docs/conf.py
index 98c1be7..dc6aa23 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -26,7 +26,6 @@ templates_path = ["_templates"]
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
-
# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
diff --git a/setup.py b/setup.py
index 50db2c2..55bc28b 100644
--- a/setup.py
+++ b/setup.py
@@ -3,7 +3,7 @@ from setuptools import setup, find_packages
setup(
name="yndx_disk",
- version="0.1",
+ version="0.2",
packages=find_packages(),
install_requires=[
"httpx", "aiofiles"
diff --git a/yndx_disk/api/resources.py b/yndx_disk/api/resources.py
index ceebbd6..03c891d 100644
--- a/yndx_disk/api/resources.py
+++ b/yndx_disk/api/resources.py
@@ -450,7 +450,7 @@ async def get_upload_url(token: str, path: str, fields: str = "", overwrite: boo
url=url,
headers=utils.generate_headers(token=token),
params={
- "path": utils.parse_path(path),
+ "path": utils.psarse_path(path),
"fields": fields,
"overwrite": overwrite,
},
diff --git a/yndx_disk/clients/async_client.py b/yndx_disk/clients/async_client.py
index 4ecd4ab..e12384d 100644
--- a/yndx_disk/clients/async_client.py
+++ b/yndx_disk/clients/async_client.py
@@ -499,6 +499,30 @@ class AsyncDiskClient:
case _:
raise api_exceptions.YandexDiskAPIException(upload_response.status_code, upload_response.text)
+ async def get_url(self, path: str = "/") -> str:
+ """
+ Retrieve the URL for a specified path on the disk.
+
+ This method fetches the URL corresponding to the provided path from the Yandex Disk. If the request is successful (status code 200), it returns the URL as a string. If the request fails, it raises a YandexDiskAPIException with the status code and description from the response.
+
+ Parameters:
+ - path (str, optional): The path for which to retrieve the URL. Defaults to "/".
+
+ Returns:
+ - str: The URL associated with the specified path.
+
+ Raises:
+ - YandexDiskAPIException: If the request fails (status code other than 200).
+ """
+ response = await api_resources.get_url(self.token, path)
+
+ response_json = response.json()
+
+ if response.status_code != 200:
+ raise api_exceptions.YandexDiskAPIException(response.status_code, response_json.get("description", ""))
+
+ return response_json.get("href", "")
+
async def listdir_trash(self, path: str = "/", limit: int = 100, offset: int = 0) -> list[File | Directory]:
"""
List the contents of a directory in the trash on the disk.
diff --git a/yndx_disk/clients/sync_client.py b/yndx_disk/clients/sync_client.py
index cc42715..4d40c99 100644
--- a/yndx_disk/clients/sync_client.py
+++ b/yndx_disk/clients/sync_client.py
@@ -35,6 +35,9 @@ class DiskClient(AsyncDiskClient):
def upload_file(self, file_path: str, path: str, overwrite: bool = False, chunk_size: int = 1024) -> None:
return asyncio.run(super().upload_file(file_path, path, overwrite, chunk_size))
+ def get_url(self, path: str = "/") -> str:
+ return asyncio.run(super().get_url(path))
+
def listdir_trash(self, path: str = "/", limit: int = 100, offset: int = 0) -> list[File | Directory]:
return asyncio.run(super().listdir_trash(path, limit, offset))