Skip to main content

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

Project description

django-fsspec

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

Features

  • fsspec compatible — use standard fsspec.filesystem("django") API
  • Multi-database — MySQL, PostgreSQL, Oracle, SQLite, and domestic databases
  • Configurable block size — tune storage granularity per deployment
  • Optimistic locking — safe concurrent writes with conflict detection
  • Block pool reuse — efficient storage with free block recycling
  • Namespace isolation — multi-tenant support via integer namespace
  • 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=0)

# 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)

Documentation

中文文档 | Chinese Documentation

License

MIT — see LICENSE.

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

django_fsspec-0.1.0.tar.gz (41.6 kB 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.1.0-py3-none-any.whl (27.1 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for django_fsspec-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8ab7b8e22d8511a3b2cc3206225e3ab11173ad0cd1957da6795b83374a87aeda
MD5 96afffb3afd770292b834216cdcb464e
BLAKE2b-256 ec874572b7cc4150c9ff82571f4027a5a7c25ab647d5f061c282e1c324409419

See more details on using hashes here.

File details

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

File metadata

  • Download URL: django_fsspec-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 27.1 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.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6e05323ff2420828f40fdb3215189ac6aa7db9825f105ea2a3b7df143762ec5b
MD5 ee4cdca9c2ec681eecd28f926d8c7bc5
BLAKE2b-256 efdcad173b7d99b5f249d44829acbb97ee21b9b6647da749dccb129e221c1c01

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