Skip to main content

Python SDK for Dilnaka file uploads

Project description

Dilnaka Python SDK

Python SDK for uploading files through the Dilnaka Upload API.

The SDK reads configuration from explicit arguments and environment variables. It requests a presigned S3 upload URL from your Dilnaka backend, uploads the file directly to S3, and calls the completion endpoint.

Install

pip install dilnaka

Configure

You can configure the SDK with your API key and optional timeout.

Configuration precedence is:

  1. Explicit constructor arguments such as Dilnaka(api_key=...)
  2. Existing process environment variables such as DILNAKA_API_KEY
  3. Values loaded from .env
  4. Built-in defaults

If you use a .env file, create it in your application project:

DILNAKA_API_KEY=dlk_dev_your_api_key_here
DILNAKA_TIMEOUT=60

The SDK base URL is fixed internally to https://dilnaka.storage.tsnc.tech. DILNAKA_TIMEOUT defaults to 60.

Basic upload

from dilnaka import Dilnaka

client = Dilnaka()

uploaded = client.upload("./test-upload.txt")

print(uploaded.id)
print(uploaded.key)
print(uploaded.status)

Explicit configuration

from dilnaka import Dilnaka

client = Dilnaka(
    api_key="dlk_dev_your_api_key_here",
)

uploaded = client.upload("./avatar.png", folder="avatars")
print(uploaded)

Request a file access URL

Use get_file_access_url(...) when you need a URL for downloading or opening a file.

from dilnaka import Dilnaka

client = Dilnaka()

access = client.get_file_access_url("file_123")

print(access.file_id)
print(access.url)
print(access.expires_in)
print(access.is_temporary)

Pass expires_in to request a temporary URL from the backend:

from dilnaka import Dilnaka

client = Dilnaka()

temporary_access = client.get_file_access_url(
  "file_123",
  expires_in=600,
)

print(temporary_access.url)
print(temporary_access.expires_in)   # 600
print(temporary_access.is_temporary) # True

expires_in must be greater than 0. If you omit it, the SDK requests the default access URL returned by your backend.

The method returns a FileAccessUrl object with:

  • file_id: Dilnaka file ID
  • url: Access URL returned by the API
  • expires_in: Expiration time in seconds when the backend returns a temporary URL
  • is_temporary: True when the backend marks the URL as temporary, or when an expiration is present

Expected backend endpoints

The SDK expects your Caspian backend to expose:

POST /v1/uploads/presign
POST /v1/uploads/complete
GET  /v1/files
GET  /v1/files/{file_id}
GET  /v1/files/{file_id}/access-url
DELETE /v1/files/{file_id}

Presign response shape

{
  "fileId": "clx_file_id",
  "fileKey": "uploads/2026/05/clx_file_id-test.txt",
  "uploadUrl": "https://s3-presigned-url",
  "expiresIn": 300,
  "method": "PUT",
  "headers": {
    "Content-Type": "text/plain"
  }
}

Complete response shape

{
  "fileId": "clx_file_id",
  "status": "uploaded",
  "key": "uploads/2026/05/clx_file_id-test.txt",
  "originalName": "test.txt",
  "contentType": "text/plain",
  "size": 94,
  "publicUrl": null
}

Access URL response shape

{
  "fileId": "clx_file_id",
  "url": "https://signed-download-url",
  "expiresIn": 600,
  "isTemporary": true
}

When a temporary URL is requested, the SDK sends:

GET /v1/files/{file_id}/access-url?expiresIn=600

Security model

The SDK never receives AWS credentials. It only receives a temporary presigned upload URL from your Dilnaka backend.

Your backend remains responsible for API key validation, scope checking, file validation, S3 key generation, metadata persistence, and upload completion verification.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dilnaka-0.0.8.tar.gz (23.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dilnaka-0.0.8-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

Details for the file dilnaka-0.0.8.tar.gz.

File metadata

  • Download URL: dilnaka-0.0.8.tar.gz
  • Upload date:
  • Size: 23.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for dilnaka-0.0.8.tar.gz
Algorithm Hash digest
SHA256 1a9b81729637a83e8e93f1ef672ba5fbba5b8391080ef99091b79865aab4430b
MD5 e7a1cc4bf037ce95ccd2a50763599e42
BLAKE2b-256 ae3a8b633807b548d7356a08067c627246a8dd4fc36eb113cf3e5b3e4eae4936

See more details on using hashes here.

File details

Details for the file dilnaka-0.0.8-py3-none-any.whl.

File metadata

  • Download URL: dilnaka-0.0.8-py3-none-any.whl
  • Upload date:
  • Size: 6.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for dilnaka-0.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 1227bed762dbd8da95ac997982a4e9e2a7f4d36bc76da0ae6fa36bfd3c65edd8
MD5 47c580d0955b2b60197b6fbf6dcee805
BLAKE2b-256 895888ac64dc48d64d09057927b6090c9e2f85d07c12f34268dcf3269de9de32

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page