Skip to main content

Python client for the Byteship file upload API.

Project description

Byteship Python SDK

Python client for the Byteship upload API.

import os
from byteship import ByteshipClient, Visibility

client = ByteshipClient(api_key=os.environ["BYTESHIP_API_KEY"])

with open("photo.jpg", "rb") as photo:
    uploaded = client.upload(
        photo,
        filename="photo.jpg",
        content_type="image/jpeg",
        path="uploads/photo.jpg",
        visibility=Visibility.PUBLIC,
    )

print(uploaded.id, uploaded.url)

Multipart Uploads

Large uploads automatically use multipart sessions when the API selects them. You can force multipart uploads and tune concurrency when you need resumable part recording:

from byteship import UploadMethod

with open("video.mp4", "rb") as video:
    uploaded = client.upload(
        video,
        filename="video.mp4",
        content_type="video/mp4",
        path="uploads/video.mp4",
        method=UploadMethod.MULTIPART,
        multipart_concurrency=4,
    )

Multipart uploads require a seekable file object so the SDK can upload part ranges independently.

Browser Upload Tokens

token = client.create_upload_token(
    folder="avatars",
    visibility=Visibility.PUBLIC,
    max_upload_bytes=10 * 1024 * 1024,
)

print(token.upload_token.token)

Private Files

with open("contract.pdf", "rb") as document:
    private_file = client.upload(
        document,
        filename="contract.pdf",
        content_type="application/pdf",
        path="contracts/contract.pdf",
        visibility=Visibility.PRIVATE,
    )

signed_url = client.create_signed_url(
    private_file.path,
    expires_in_seconds=15 * 60,
)

print(signed_url.signed_url.url)

Image URLs

from byteship import image_srcset, image_url

src = image_url(uploaded.url, {"width": 800, "format": "webp"})
srcset = image_srcset(
    uploaded.url,
    widths=[320, 640, 960],
    transform={"fit": "cover", "height": 400, "format": "webp"},
)

Features

  • upload creates an upload session, streams bytes to storage, and completes it, including multipart uploads when selected.
  • upload_many uploads batches with bounded concurrency.
  • create_upload_token mints scoped browser upload tokens from trusted server code.
  • create_file_upload, create_upload, create_upload_part_urls, complete_path_upload, and complete_upload expose the lower-level upload lifecycle.
  • get_file, create_signed_url, and delete_file cover file management and private delivery.
  • image_url and image_srcset build Byteship tr transform URLs for responsive images.
  • ByteshipError exposes structured API errors with code, status, and details.
  • No runtime dependencies; the SDK uses the Python standard library.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

byteship-0.1.5.tar.gz (13.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

byteship-0.1.5-py3-none-any.whl (10.4 kB view details)

Uploaded Python 3

File details

Details for the file byteship-0.1.5.tar.gz.

File metadata

  • Download URL: byteship-0.1.5.tar.gz
  • Upload date:
  • Size: 13.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for byteship-0.1.5.tar.gz
Algorithm Hash digest
SHA256 e88cbba99a058511a65ceca77567a8df24e6b4358af76dbebc25f04c36463c44
MD5 a50cf6b8df9c2893b5cb79f17242c778
BLAKE2b-256 5715df553c3340e4df8e878d5b4b9d99ea969431a5766ff07c192addb271ac87

See more details on using hashes here.

File details

Details for the file byteship-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: byteship-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 10.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for byteship-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 d2458c4f535b7d70c4ac7946d012a79cb576ea2f5994e79790ef34b63058c121
MD5 41e049f67b4bcb8b75daf24c5833c6bb
BLAKE2b-256 de43443886213eb1000fdb05fb2cb74d79eb435c5a18b0a611446051d9da2576

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page