Metadata-Version: 2.1
Name: django-s3-file-field-client
Version: 0.2.0
Summary: A Python client library for django-s3-file-field.
Home-page: https://github.com/girder/django-s3-file-field
Author: Kitware, Inc.
Author-email: kitware@kitware.com
License: Apache 2.0
Project-URL: Bug Reports, https://github.com/girder/django-s3-file-field/issues
Project-URL: Source, https://github.com/girder/django-s3-file-field
Keywords: django girder
Platform: UNKNOWN
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Web Environment
Classifier: Framework :: Django :: 3.0
Classifier: Framework :: Django
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python
Requires-Python: >=3.8
Description-Content-Type: text/markdown
Requires-Dist: requests

# django-s3-file-field-client
[![PyPI](https://img.shields.io/pypi/v/django-s3-file-field-client)](https://pypi.org/project/django-s3-file-field-client/)

A Python client library for django-s3-file-field.

## Installation
```bash
pip install django-s3-file-field-client
```

## Usage
```python
import requests
from s3_file_field_client import S3FileFieldClient

api_client = requests.Session()  # This can be used to set authentication headers, etc.

s3ff_client = S3FileFieldClient(
    'http://localhost:8000/api/v1/s3-upload/',  # The path mounted in urlpatterns
    api_client,  # This argument is optional
)
with open('/path/to/my_file.txt', 'rb') as file_stream:  # Open in binary mode
    field_value = s3ff_client.upload_file(
        file_stream,  # This can be any file-like object
        'my_file.txt',
        'core.File.blob'  # The "<app>.<model>.<field>" to upload to
    )

api_client.post(
    'http://localhost:8000/api/v1/file/',  # This is particular to the application
    json={
        'blob': field_value,  # This should match the field uploaded to (e.g. 'core.File.blob')
        ...: ...,   # Other fields for the POST request 
    }
)
```


