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)

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)

Features

  • upload creates an upload session, streams bytes to storage, and completes it.
  • upload_many uploads batches with bounded concurrency.
  • create_upload_token mints scoped browser upload tokens from trusted server code.
  • create_file_upload, create_upload, and complete_upload expose the lower-level upload lifecycle.
  • get_file, create_signed_url, and delete_file cover file management and private delivery.
  • 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.1.tar.gz (9.9 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.1-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for byteship-0.1.1.tar.gz
Algorithm Hash digest
SHA256 c760e4af9f8dea2d5cf43feb5018746ab235fe637a24e627d7b4b3d8b04b5422
MD5 ffa36c29a83516c0d94e2eb0145e7582
BLAKE2b-256 207f7532dbd3abf9ab62b0f0ce942052e189751d0a02e6eeaface38930751908

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for byteship-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 aaa7b5eafe3d0c69b8482a4116794e5cbabfb3599e07cb2c8d015b7106b34497
MD5 8d8c297740eeab259920ed84ddf80793
BLAKE2b-256 7ed12215dc1dbe132f3b980e7c123b5ff8c0fa22f9b312e86d5cf17dbce096bb

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