Skip to main content

django-s3-file-field-client

PyPI

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

Installation

pip install django-s3-file-field-client

Usage

import mimetypes
import pathlib
import requests
from s3_file_field_client import S3FileFieldClient

file_to_upload = pathlib.Path("/path/to/my_file.txt")
with (
    S3FileFieldClient(
        "http://localhost:8000/api/v1/s3-upload/",  # The path mounted in urlpatterns
        headers={"Authorization": "Token ..."},  # Headers for the API's requests; optional
    ) as s3ff_client,
    file_to_upload.open("rb") as file_stream,  # Open in binary mode
):
    field_value = s3ff_client.upload_file(
        file_stream=file_stream,  # This can be any seekable file-like object
        file_name=file_to_upload.name,
        file_content_type=mimetypes.guess_type(file_to_upload)[0],
        field_id="core.File.blob",  # The "<app>.<model>.<field>" to upload to
    )

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

Errors

A failed upload raises an S3FileFieldError, whose message is suitable for display. Its status is the HTTP status of the response, if one was received, and its __cause__ is the underlying requests exception, when there is one.

Metadata

Release files for django-s3-file-field-client 2.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-s3-file-field-client 2.0.2
File Size Uploaded Provenance Actions
django_s3_file_field_client-2.0.2.tar.gz 8.5 kB Without provenance Details for django_s3_file_field_client-2.0.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for django-s3-file-field-client 2.0.2
File Interpreter ABI Platform Actions
django_s3_file_field_client-2.0.2-py3-none-any.whl Python 3 none any Details for django_s3_file_field_client-2.0.2-py3-none-any.whl

Total release size: 16.2 kB

Release files / django_s3_file_field_client-2.0.2.tar.gz

Download URL django_s3_file_field_client-2.0.2.tar.gz
Size 8.5 kB
Tags Source
SHA-256 checksum
How to use checksums
e2094a523cb58cfc848ba4ed9fea15df61ecd98d7f4d637118e40118eca9ce6f
BLAKE2b-256 checksum
How to use checksums
e4815efe26347e8894579ee6836ffeadebbd34ecd5db2290b1e8b1e0bfcb5d4d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / django_s3_file_field_client-2.0.2-py3-none-any.whl

Download URL django_s3_file_field_client-2.0.2-py3-none-any.whl
Size 7.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
29938849ae02df5687cb1543c89d7ef1a6399dab9d1f51d08d295d94ba768362
BLAKE2b-256 checksum
How to use checksums
865b8b483620f8930c25d491211ffd0478aebfcfc109622d156b72c8cf752b37
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for django-s3-file-field-client 2.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page