هر تغییری در api ایجاد شه در اولین فرصت بروز میکنم
loopy
-
کتابخانه پایتون برای وب سرویس فایلز - Files.ir -
کتابخانه پایتون برای وب سرویس فایلز - Files.irسلام معرفی کتابخانه async برای api وبسایت - افزونه غیر رسمی - توسط تیم فایلز تست نشده است
https://github.com/loopy-iri/aiofilesir
filesir-async-client
Asynchronous Python 3.10+ client for the Files.ir REST API.
Built on
httpx.AsyncClientandpydanticv2. Provides typed coroutines for every endpoint
in the OpenAPI spec, automatic Bearer-token injection, configurable retry + exponential
backoff, and a high-levelupload_filehelper that auto-selects the right session-based
upload strategy (single,s3-single,s3-multipart,tus).Install
From PyPI (when published):
pip install filesir-async-clientDirectly from this Git repository (recommended for now):
pip install "git+https://github.com/loopy-iri/aiofilesir.git"Pin to a tag or branch:
pip install "git+https://github.com/loopy-iri/aiofilesir.git@v0.1.0" pip install "git+https://github.com/loopy-iri/aiofilesir.git@main"Add to
requirements.txt:filesir-async-client @ git+https://github.com/loopy-iri/aiofilesir.git@mainQuick start
import asyncio from filesir import FilesIrClient async def main() -> None: async with FilesIrClient(access_token="pat_...") as client: usage = await client.storage.space_usage() print(usage.used, usage.available, usage.remaining) folder = await client.folders.create(name="reports") entry = await client.uploads.upload_file( "/tmp/big-video.mp4", parent_id=folder.id, progress=lambda done, total: print(f"{done}/{total}"), ) # Build a direct GET URL with the access token in the query string. url = client.files.direct_download_url(entry.id) print("Direct URL:", url) await client.files.download_to_file(entry.id, "/tmp/copy.mp4") asyncio.run(main())Authentication
# From an existing personal access token (account settings > developers). client = FilesIrClient(access_token="pat_...") # Or login by email/password and receive a token automatically. client = await FilesIrClient.from_credentials( email="me@example.com", password="secret", token_name="my-script", )Resources
client.auth— register / loginclient.storage— space usageclient.files— list / update / delete / move / duplicate / restore / download /direct_download_urlclient.folders— create folderclient.uploads—upload_file()(auto-strategy) /upload_legacy()/ low-level sessionsclient.sharing— share / change-permissions / unshareclient.starring— star / unstarclient.links— shareable linksclient.workspaces— CRUD + members + invites + activity logsclient.tags— list / attach / detach / sync
Live test script
examples/live_upload_and_link.pyuploads a real file, prints the direct
download URL and creates a public shareable link. Pass your token via the
FILESIR_TOKENenvironment variable (or editFALLBACK_TOKENinside the
script):export FILESIR_TOKEN=pat_xxxxxxxxxxxx python examples/live_upload_and_link.py /path/to/local-file.pngLicense
MIT.