A Python client library for django-s3-file-field.
Project description
django-s3-file-field-client
A Python client library for django-s3-file-field.
Installation
pip install django-s3-file-field-client
Usage
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
}
)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for django-s3-file-field-client-0.3.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5bbb8775e03627f471bc600a88de61ae8f09036b75831e8f3281ece43d6df124 |
|
MD5 | 4e42b34d4d9886a64e0871df3c6a8516 |
|
BLAKE2b-256 | ae4c7b131baafdadf4778fa69ce0f1a841b5a58378fba177abdd4ce75507d742 |
Close
Hashes for django_s3_file_field_client-0.3.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4cc57e5a57ff300c38c87373af642fb858e191728a4c688cb44d502f874d3374 |
|
MD5 | a7225b865872eed3ba5625c20c85a151 |
|
BLAKE2b-256 | 4ab9b760c9036de39242536f74d737a4465f19628740809855d827a6e7444070 |