Skip to main content

light-s3-client

Purpose

The AWS Boto3 Client is quite heavy, and usually specific functionality is needed. This module only implements needed functionality using the requests library and the S3 REST API.

Reference doc used for this creation: https://docs.aws.amazon.com/AmazonS3/latest/API/sig-v4-authenticating-requests.html#signing-request-intro

Note: The parameter names and function names were copied from the Boto3 S3 Client. It does not necessarily have all the options for the function

Supported Functions

Client.download_file(Bucket, Key, Filename)

Download an S3 object to a file.

Usage:

from light_s3_client import Client

s3 = Client(
    region="us-west-1",
    access_key="REPLACE_ME",
    secret_key="REPLACE_ME"
)
s3.download_file("mybucket", "hello.txt", "/tmp/hello.txt")

PARAMETERS:

  • Bucket (str) – The name of the bucket to download from.
  • Key (str) – The name of the key to download from.
  • Filename (str) – The path to the file to download to.

Client.upload_fileobj(Fileobj, Bucket, Key)

Upload a file object to S3. The Content-Type header is automatically inferred from the file extension.

Usage:

from light_s3_client import Client
import json


def get_file_contents(file_name) -> bytes:
    file_handle = open(file_name, "r")
    content = json.load(file_handle)
    str_content = json.dumps(content)
    file_handle.close()
    data = str_content.encode("utf-8")
    return data


s3 = Client(
    region="us-west-1",
    access_key="REPLACE_ME",
    secret_key="REPLACE_ME"
)
upload_data = get_file_contents("example.json")
s3.upload_fileobj(upload_data, "example-bucket", "path/example.json")

PARAMETERS:

  • Fileobj (bytes, io.BytesIO, io.BufferedReader, or io.TextIOWrapper) – A file-like object or bytes to upload.
  • Bucket (str) – The name of the bucket to upload to.
  • Key (str) – The name of the key to upload to.

Client.upload_file_multipart(Fileobj, Bucket, Key, part_size, max_parts)

Upload a file to S3 using multipart upload for large files. Falls back to regular upload if the file is smaller than part_size.

Usage:

from light_s3_client import Client

s3 = Client(
    region="us-west-1",
    access_key="REPLACE_ME",
    secret_key="REPLACE_ME"
)
with open("large_file.bin", "rb") as f:
    s3.upload_file_multipart(f, "example-bucket", "path/large_file.bin")

PARAMETERS:

  • Fileobj (bytes, io.BytesIO, io.BufferedReader, or io.TextIOWrapper) – A file-like object or bytes to upload.
  • Bucket (str) – The name of the bucket to upload to.
  • Key (str) – The name of the key to upload to.
  • part_size (int, optional) – Size of each part in bytes. Default is 5MB (5242880).
  • max_parts (int, optional) – Maximum number of parts allowed. Default is 10000.

Client.delete_file(Bucket, Key)

Delete an S3 object. Returns True if the deletion was successful, False otherwise.

Usage:

from light_s3_client import Client

s3 = Client(
    region="us-west-1",
    access_key="REPLACE_ME",
    secret_key="REPLACE_ME"
)
result = s3.delete_file("example-bucket", "path/example.json")
print(f"Delete result: {result}")  # True if successful, False otherwise

Client.list_objects(Bucket, Prefix)

List all keys in an S3 bucket with a given prefix.

Usage:

from light_s3_client import Client

s3 = Client(
    region="us-west-1",
    access_key="REPLACE_ME",
    secret_key="REPLACE_ME"
)
objects = s3.list_objects("example-bucket", "path/")
print(f"Found {len(objects)} objects")

Client.get_object(Bucket, Key)

Check if an S3 object exists. Returns True if the object exists, False otherwise.

Usage:

from light_s3_client import Client

s3 = Client(
    region="us-west-1",
    access_key="REPLACE_ME",
    secret_key="REPLACE_ME"
)
exists = s3.get_object("example-bucket", "path/example.json")
print(f"Object exists: {exists}")  # True if exists, False otherwise

Client.head_object(Bucket, Key)

Check if an S3 object exists and return its metadata. Returns a dictionary with metadata if the object exists, or an empty dictionary otherwise.

Usage:

from light_s3_client import Client

s3 = Client(
    region="us-west-1",
    access_key="REPLACE_ME",
    secret_key="REPLACE_ME"
)
metadata = s3.head_object("example-bucket", "path/example.json")
print(f"Object metadata: {metadata}")  # Dictionary with metadata or empty dict

Client.put_object_tagging(Bucket, Key, Tags)

Set tags for an S3 object. Returns True if successful, False otherwise.

Usage:

from light_s3_client import Client

s3 = Client(
    region="us-west-1",
    access_key="REPLACE_ME",
    secret_key="REPLACE_ME"
)
tags = {"Environment": "Production", "Owner": "John Doe"}
result = s3.put_object_tagging("example-bucket", "path/example.json", tags)
print(f"Tagging result: {result}")  # True if successful, False otherwise

Client.get_object_tagging(Bucket, Key)

Retrieve tags for an S3 object. Returns a dictionary of tag key-value pairs if successful, or an empty dictionary otherwise.

Usage:

from light_s3_client import Client

s3 = Client(
    region="us-west-1",
    access_key="REPLACE_ME",
    secret_key="REPLACE_ME"
)
tags = s3.get_object_tagging("example-bucket", "path/example.json")
print(f"Object tags: {tags}")  # Dictionary with tags or empty dict

Client Initialization Parameters

Property Required Type Default Description
region True string The S3 region being used
access_key True string The AWS Access Key for API Access
secret_key True string The AWS Secret Key for API Access
server False string None An override of the HTTPS URL to use
encryption False string "AES256" The encryption algorithm to use for uploads
signature_version False string "v4" AWS signature version ("v2" or "v4")

Authentication

This library implements AWS Signature Version 4 authentication by default, following the same signing standard as boto3. Legacy Signature Version 2 is also supported.

Usage:

from light_s3_client import Client

# Default: Signature V4 (recommended, works with AWS and modern MinIO)
s3 = Client(
    region="us-west-1",
    access_key="REPLACE_ME",
    secret_key="REPLACE_ME"
)

# Legacy: Signature V2 (for older S3-compatible services)
s3 = Client(
    region="us-west-1",
    access_key="REPLACE_ME",
    secret_key="REPLACE_ME",
    signature_version="v2"
)

# Custom S3-compatible server (e.g. MinIO)
s3 = Client(
    region="us-east-1",
    access_key="minioadmin",
    secret_key="minioadmin",
    server="http://localhost:9000"
)

Download files

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

Source Distribution

light_s3_client-0.0.40.tar.gz (11.3 kB view details)

Uploaded Source

Built Distribution

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

light_s3_client-0.0.40-py3-none-any.whl (15.7 kB view details)

Uploaded Python 3

File details

Details for the file light_s3_client-0.0.40.tar.gz.

File metadata

  • Download URL: light_s3_client-0.0.40.tar.gz
  • Upload date:
  • Size: 11.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for light_s3_client-0.0.40.tar.gz
Algorithm Hash digest
SHA256 73cd22d141a19813b5351edebd962db00a770d26be52e3c47eae5ce5d3b41851
MD5 45d6bbcf96f5e6e7ead5d89ca5a9646e
BLAKE2b-256 ba3ee3b09bf358e030f43bb1a71e95b5517473e7bfd54a0e6e82bb4a13233d25

See more details on using hashes here.

Provenance

The following attestation bundles were made for light_s3_client-0.0.40.tar.gz:

Publisher: python-publish.yml on dougbotai/light-s3-client

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file light_s3_client-0.0.40-py3-none-any.whl.

File metadata

File hashes

Hashes for light_s3_client-0.0.40-py3-none-any.whl
Algorithm Hash digest
SHA256 9bea67138cc1b451965ee559f7f34e6b6818c2cd1b725f7eb6abccb03b9800a8
MD5 73f16577585276141afe3f3073a120e3
BLAKE2b-256 3ff7dc0da16ce05f84d03428f33b391b5ef855db323eeb887c3b66e2e57fe89f

See more details on using hashes here.

Provenance

The following attestation bundles were made for light_s3_client-0.0.40-py3-none-any.whl:

Publisher: python-publish.yml on dougbotai/light-s3-client

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.0.40 This release

2 files

0.0.39

2 files

0.0.30

2 files

0.0.29

2 files

0.0.27

2 files

0.0.20

2 files

0.0.19

2 files

0.0.18

2 files

0.0.17

2 files

0.0.16

2 files

0.0.15

2 files

0.0.14

2 files

0.0.13

2 files

0.0.12

2 files

0.0.11

2 files

Supported by

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