Skip to main content

A lightweight S3 client.

Project description

Purpose

The AWS Boto3 Client is quite heavy, and usually specific functionality is needed. This module only implements needed functionality uses the requests library and the S3 Resp 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 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

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 (a file-like object) – A file-like object to upload. At a minimum, it must implement the read method, and must return bytes.

  • Bucket (str) – The name of the bucket to upload to.

  • Key (str) – The name of the key to upload to.

Client.delete_object(Bucket, Key)

Delete a S3 object

Usage:

from light_s3_client import Client

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

PARAMETERS:

  • Bucket (str) – The name of the bucket to upload to.

  • Key (str) – The name of the key to upload to.(Fileobj, Bucket, Key)

Client.list_objects(Bucket, Prefix)

Lists all keys in an object

Usage:

from light_s3_client import Client

s3 = Client(
    region="us-west-1",
    access_key="REPLACE_ME",
    secret_key="REPLACE_ME"
)
keys = s3.list_objects("example-bucket", "prefix")

PARAMETERS:

  • Bucket (str) – The name of the bucket to upload to.

  • Prefix (str) – The prefix to use as the search for getting keys from the bucket

Client.get_object(Bucket, Key)

Returns if an object exists or not

Usage:

from light_s3_client import Client

s3 = Client(
    region="us-west-1",
    access_key="REPLACE_ME",
    secret_key="REPLACE_ME"
)
keys = s3.get_object("example-bucket", "path/file.txt")

PARAMETERS:

  • Bucket (str) – The name of the bucket to upload to.

  • Key (str) – The key to check if it exists in the bucket

Client Parameters

property

Required

type

description

region

True

string

The S3 region being used. This ends up as part of the Server URL

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

An override of the HTTPS URL to use. When used then region is not used

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

light_s3_client-0.0.30.tar.gz (7.6 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.30-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: light_s3_client-0.0.30.tar.gz
  • Upload date:
  • Size: 7.6 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.30.tar.gz
Algorithm Hash digest
SHA256 91bcdbf51b7f15f2b947acd180df81eb890577a3b36636519c9b054edb641ee5
MD5 2c69c0ba2695e247d7d351225276a58f
BLAKE2b-256 d5ddd42c0badca0071e19e004ce2c783dac3a1c646d5a7b59b65d0ec79be3f9f

See more details on using hashes here.

Provenance

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

Publisher: python-publish.yml on dacoburn/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.30-py3-none-any.whl.

File metadata

File hashes

Hashes for light_s3_client-0.0.30-py3-none-any.whl
Algorithm Hash digest
SHA256 c60275b0c2d3fd7576ba30729c581468dac8a6b466d1e92b52a3a4773fa05461
MD5 0eb8f37c64a24cc855b2cca3ec375a12
BLAKE2b-256 cb185bf1ce41bbba606f48c08423c3fd03172e3eabe5c71b3d82189aa9d55508

See more details on using hashes here.

Provenance

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

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

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

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