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_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: 256KB)
DJANGO_FSSPEC_BLOCK_SIZE = 64 * 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), default 256KB block size. Push/PR CI runs the bounded benchmark scale (--scale ci --seed 1) and uploads JSON artifacts that include database, backend, scale, and seed metadata.

Operation SQLite MySQL 8.0 PostgreSQL 16 Oracle 23
Write small (100B) 2.2ms (450/s) 4.4ms (226/s) 3.0ms (333/s) 3.2ms (313/s)
Write medium (10KB) 2.3ms (433/s) 4.9ms (204/s) 3.1ms (321/s) 3.6ms (277/s)
Write large (1MB) 6.6ms (151/s) 28.0ms (36/s) 24.0ms (42/s) 11.3ms (88/s)
Read small (100B) 1.2ms (841/s) 2.4ms (411/s) 2.3ms (431/s) 2.6ms (390/s)
Read large (1MB) 1.7ms (598/s) 4.5ms (223/s) 7.8ms (129/s) 5.5ms (183/s)
List 1000 files 2.5ms (394/s) 5.9ms (168/s) 3.9ms (254/s) 6.0ms (167/s)
Delete 2.4ms (413/s) 5.3ms (188/s) 3.5ms (284/s) 3.7ms (268/s)

Full benchmark results (including concurrency tests) are collected by CI on every push and available as GitHub Actions artifacts.

For larger seeded datasets, run the manual GitHub Actions workflow “Large Benchmark”. It accepts database (sqlite, mysql, postgres, oracle), scale (medium, large), seed, and optional scenario inputs. These runs include seeded ls, exists, info, and find scenarios and upload JSON artifacts named with the database, scale, and seed.

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.1.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.1-py3-none-any.whl (34.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: django_fsspec-0.2.1.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.1.tar.gz
Algorithm Hash digest
SHA256 92957fd273323a01a12afdbcf99e851cec96f545e9713a4c47d8962a033e997e
MD5 1c25bbfbd16d3b20a332238edab3e6fd
BLAKE2b-256 fce0bbfa210a49e816699351bae13b21a205a8ab5bf24c2b09823f7542750cfb

See more details on using hashes here.

File details

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

File metadata

  • Download URL: django_fsspec-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 34.4 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9345c3ab16c886fe08644adcd6753158941439f23867e9360546edcc021a1b5c
MD5 d9dbc95284450f8558182ce199d7deff
BLAKE2b-256 5bfd8e207dc0db9df5ed35b62a426469e829af371b6c209f8972bd6359ad9596

See more details on using hashes here.

Release history Release notifications | RSS feed

0.2.3

2 files

0.2.2

2 files

This release

0.2.1 This release

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