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,
    )

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, 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.
  • 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.3.tar.gz (12.7 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.3-py3-none-any.whl (9.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: byteship-0.1.3.tar.gz
  • Upload date:
  • Size: 12.7 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.3.tar.gz
Algorithm Hash digest
SHA256 609daf9d85a6f9e5bbc820c09c48b181e3f43bf029500766a38bad943dc627f4
MD5 0f9970aae71b8ff952ab1ab925c1d4e0
BLAKE2b-256 5f75bd09eeacb2585503c77e1d4df18b7108fed0638862e6bbfec4ca9f2b763b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: byteship-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 9.2 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 d9083ef1b551e697b13db12c427cc236a3f6844da5c8e2293361809acc3c3ac3
MD5 9abadcb746c740961c417da32f8a0338
BLAKE2b-256 0991887932cd8131e65699504152b0c88249afa60b9f144301ee37d5a38af01f

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