Metadata-Version: 2.4
Name: django-railway-storage
Version: 1.0.0
Summary: Django storage backends and auto-configuration for Railway bucket storage.
License: MIT License
        
        Copyright (c) 2026
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://github.com/Franklinson/Railway-Storage
Project-URL: Issues, https://github.com/Franklinson/Railway-Storage/issues
Classifier: Framework :: Django
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: django>=3.2
Requires-Dist: django-storages[s3]>=1.13
Requires-Dist: boto3>=1.20
Requires-Dist: botocore>=1.23
Provides-Extra: test
Requires-Dist: pytest; extra == "test"
Requires-Dist: pytest-django; extra == "test"
Dynamic: license-file

# django-railway-storage

A Django package that provides Railway bucket storage backends and a management command to auto-configure your settings.

## Installation

```bash
pip install django-railway-storage
```

Add to `INSTALLED_APPS`:

```python
INSTALLED_APPS = [
    ...
    'django_railway_storage',
]
```

## Usage

### Auto-configure settings

Run the management command to append the storage config to your settings file:

```bash
# Private storage (presigned URLs, default)
python manage.py configure_railway_storage

# Public storage
python manage.py configure_railway_storage --storage public

# Custom settings file path
python manage.py configure_railway_storage --settings-file config/settings/production.py

# Custom presigned URL expiry (seconds)
python manage.py configure_railway_storage --storage private --expire 7200
```

### Required environment variables

Set these in your Railway project (or `.env`):

| Variable | Description |
|---|---|
| `AWS_ACCESS_KEY_ID` | Railway bucket access key |
| `AWS_SECRET_ACCESS_KEY` | Railway bucket secret key |
| `AWS_STORAGE_BUCKET_NAME` | Bucket name |
| `AWS_S3_ENDPOINT_URL` | Railway S3-compatible endpoint URL |
| `AWS_S3_REGION_NAME` | Region (default: `us-east-1`) |

### Use backends directly

You can also reference the backends manually in your settings:

```python
# Private (presigned URLs)
STORAGES = {
    "default": {
        "BACKEND": "django_railway_storage.backends.PrivateMediaStorage",
    },
    ...
}

# Public
STORAGES = {
    "default": {
        "BACKEND": "django_railway_storage.backends.PublicMediaStorage",
    },
    ...
}
```

### Use on a model field

```python
from django.db import models

class Document(models.Model):
    file = models.FileField(upload_to='documents/')  # uses default storage
```
