Skip to main content

django-fsspec

A Django app that provides a file system interface via fsspec, backed by Django ORM.

django-fsspec architecture

Features

  • fsspec compatible — use standard fsspec.filesystem("django") API
  • Multi-database — works through Django ORM on supported relational databases
  • Configurable block size — tune storage granularity per deployment
  • Optimistic locking — safe concurrent writes with conflict detection
  • Append-safe API — append mode uses the same database-backed append operation as the public API
  • Namespace partitioning — separate path spaces via integer namespace; authorization remains the host app's responsibility
  • Path validation — blacklist rules + Unicode NFC normalization
  • Implicit directories — no directory records, derived from file paths
  • Management commandsfsspec_gc, fsspec_fsck, fsspec_repair, fsspec_rechunk, fsspec_stats

Quick Start

pip install django-fsspec

Add to INSTALLED_APPS:

INSTALLED_APPS = [
    ...
    "django_fsspec",
]

Run migrations:

python manage.py migrate

Use it:

import fsspec

fs = fsspec.filesystem("django", namespace_id=1)

# Write
with fs.open("/hello.txt", "wb") as f:
    f.write(b"Hello World")

# Read
data = fs.cat("/hello.txt")  # b"Hello World"

# List
fs.ls("/")  # ["/hello.txt"]

# Delete
fs.rm("/hello.txt")

Configuration

Add to your Django settings.py:

# Block size in bytes (default: 32KB)
DJANGO_FSSPEC_BLOCK_SIZE = 32 * 1024

# Maximum file size in bytes (default: 2MB)
DJANGO_FSSPEC_MAX_FILE_SIZE = 2 * 1024 * 1024

Supported File Modes

Mode Description
rb Read (file must exist)
wb Write (create or overwrite)
ab Append (create or append)
xb Exclusive create (file must not exist)

Performance

Benchmarked on GitHub Actions (ubuntu-latest), using the historical 256KB block size. The table below uses CI run 28412676243 on commit 2236341 with --scale ci --seed 1. Format: average latency (throughput).

Operation SQLite MySQL 8.0 / Django 4.2 MySQL 8.0 / Django 5.2 PostgreSQL 16 / Django 4.2 PostgreSQL 16 / Django 5.2 Oracle 23
Write small (100B) 4.2ms (237/s) 7.7ms (129/s) 7.2ms (138/s) 6.6ms (152/s) 6.4ms (157/s) 6.3ms (159/s)
Write medium (10KB) 4.4ms (228/s) 8.1ms (124/s) 7.7ms (130/s) 6.6ms (153/s) 6.2ms (160/s) 6.5ms (153/s)
Write large (1MB) 8.4ms (118/s) 30.2ms (33/s) 30.0ms (33/s) 33.4ms (30/s) 29.9ms (33/s) 14.0ms (71/s)
Read small (100B) 1.4ms (693/s) 2.6ms (381/s) 2.4ms (409/s) 3.0ms (338/s) 2.5ms (393/s) 2.8ms (355/s)
Read large (1MB) 1.9ms (536/s) 4.6ms (219/s) 4.3ms (235/s) 9.5ms (106/s) 9.5ms (105/s) 5.3ms (188/s)
List 1000 files 4.3ms (234/s) 7.1ms (141/s) 6.8ms (147/s) 7.0ms (144/s) 6.5ms (153/s) 7.6ms (132/s)
Delete 3.4ms (294/s) 7.0ms (143/s) 6.4ms (156/s) 5.2ms (193/s) 5.0ms (199/s) 5.1ms (196/s)

Full benchmark results, including concurrency and manually triggered seeded runs, are documented in Benchmarks and available as GitHub Actions artifacts.

Documentation

中文文档 | Chinese Documentation

License

MIT — see LICENSE.

Download files

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

Source Distribution

django_fsspec-0.2.2.tar.gz (1.2 MB view details)

Uploaded Source

Built Distribution

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

django_fsspec-0.2.2-py3-none-any.whl (41.3 kB view details)

Uploaded Python 3

File details

Details for the file django_fsspec-0.2.2.tar.gz.

File metadata

  • Download URL: django_fsspec-0.2.2.tar.gz
  • Upload date:
  • Size: 1.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for django_fsspec-0.2.2.tar.gz
Algorithm Hash digest
SHA256 1cb94f6875770dccd17c6242ade166952e2106f0358d62fc9aaeff473579c53a
MD5 7b75acd05af40d6eef07de8929b8eb6b
BLAKE2b-256 4a6e6544a308f65ba3a4950042622ef597ca784bfe137aa2f20c860a83a438f7

See more details on using hashes here.

File details

Details for the file django_fsspec-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: django_fsspec-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 41.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for django_fsspec-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b24bdcc4c9b1f1ca49c4152538c06c24aac33aea68713a887d6385bf7f779159
MD5 ce2b36886eaae7481dfb8676632371a7
BLAKE2b-256 4a805bce89d6a8c8475dd4831874630be560e0efb1da92c7a5e1800a4b27cada

See more details on using hashes here.

Release history Release notifications | RSS feed

0.2.3

2 files

This release

0.2.2 This release

2 files

0.2.1

2 files

0.2.0

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page