Tentaclio S3

0.0.3 · active · verified Sat Apr 11

Tentaclio-s3 is a Python package that provides all the necessary dependencies to enable S3 protocol support within the `tentaclio` library. The `tentaclio` library itself simplifies handling streams from various protocols (like file, ftp, sftp, s3) and manages credentials. Tentaclio-s3, currently at version 0.0.3, acts as an 'extra' dependency for tentaclio, not a standalone library for direct S3 interaction.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to use `tentaclio.open` to write to and read from an S3 path. It assumes AWS credentials (e.g., `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, `AWS_REGION`) are configured in the environment or via other `boto3` supported methods. The `tentaclio-s3` package is automatically utilized when an `s3://` URL is provided to `tentaclio.open`.

import os
from tentaclio import open

# Ensure AWS credentials are set via environment variables (e.g., AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)
# or other boto3-supported methods (IAM role, ~/.aws/credentials).
# For demonstration, we'll use a dummy bucket and key.
S3_BUCKET = os.environ.get('TEST_S3_BUCKET', 'your-test-s3-bucket')
S3_KEY = os.environ.get('TEST_S3_KEY', 'path/to/my_file.txt')
S3_PATH = f"s3://{S3_BUCKET}/{S3_KEY}

# Example: Write to an S3 file
content_to_write = "Hello from tentaclio-s3!"
try:
    with open(S3_PATH, mode="w") as writer:
        writer.write(content_to_write)
    print(f"Content successfully written to {S3_PATH}")

    # Example: Read from an S3 file
    with open(S3_PATH, mode="r") as reader:
        read_content = reader.read()
    print(f"Content read from {S3_PATH}: {read_content}")

except Exception as e:
    print(f"An error occurred: {e}")
    print("Please ensure your AWS credentials are configured and the S3 bucket/key are accessible.")

view raw JSON →