Metadata-Version: 2.4
Name: django-cloud-storage
Version: 1.0.7
Summary: Custom storage backend tailored for a proprietary cloud storage service.
Author-email: cybermeh <cybermeh@icloud.com>
Classifier: Environment :: Web Environment
Classifier: Framework :: Django
Classifier: Framework :: Django :: 4.2
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: BSD License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Topic :: Internet :: WWW/HTTP
Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: django>=4.2
Requires-Dist: requests>=2.31.0
Dynamic: license-file

# Django Cloud Storage


Django Cloud Storage is a Python package that provides a custom storage backend designed for seamless integration with 
proprietary cloud storage service.

## Installation

```bash
pip install django-cloud-storage
```

## Configuration

In your Django settings file, set the following values:

```python
CLOUD_STORAGE_URL = 'https://your-cloud-service.com'
CLOUD_STORAGE_API_TOKEN = 'your-api-token'
CLOUD_STORAGE_PROJECT_ALIAS = 'myproject'
```

### Optional settings

| Setting | Default | Description |
|--------|---------|-------------|
| `CLOUD_STORAGE_VERIFY` | `True` | TLS verification, passed to [Requests](https://requests.readthedocs.io/en/latest/user/advanced/#ssl-cert-verification): use `False` only for local development with self-signed certificates, or a string path to a CA bundle for private CAs. |
| `CLOUD_STORAGE_TIMEOUT` | `30` | Request timeout in seconds (or a `(connect, read)` tuple as supported by Requests). |

The client reuses HTTP connections via a `requests.Session`, and opening a file for reading (`'rb'` / `'r'`) performs a single download instead of a separate existence check followed by a read.

**Security:** Setting `CLOUD_STORAGE_VERIFY = False` disables certificate validation and exposes you to man-in-the-middle attacks. Prefer installing your CA or pointing `CLOUD_STORAGE_VERIFY` at a PEM bundle when using internal certificate authorities.

```python
# Example: internal CA (recommended over verify=False)
CLOUD_STORAGE_VERIFY = '/etc/ssl/certs/my-org-ca.pem'

# Example: local dev only (insecure)
CLOUD_STORAGE_VERIFY = False
```

## Usage
To integrate the Cloud Storage with a Django model, follow these steps:

* Import the required models and CloudStorage:
    ```python
    from django_cloud_storage.storage import CloudStorage
    ```
* Define your Django model, using `CloudStorage` as the storage backend for a `FileField`:

    ```python
    class MyModel(models.Model):
        file_field = models.FileField(storage=CloudStorage)

        def __str__(self):
            return self.file_field.name
    ```
