s3
Scannednpx machina-cli add skill yugasun/skills/s3 --openclawS3 Deployment Skill
Instructions
This skill handles uploading a local directory (e.g., generated slides) to an AWS S3 bucket or any S3-compatible object storage (e.g., MinIO, Aliyun OSS, Tencent COS) for static website hosting.
-
Prerequisites:
- Ensure the user has valid credentials in their environment:
S3_ACCESS_KEY_IDS3_SECRET_ACCESS_KEYS3_BUCKET(Optional if provided as an argument)S3_REGION(Optional)S3_ENDPOINT_URL(Required for non-AWS services like MinIO or Aliyun OSS)S3_CUSTOM_DOMAIN(Optional, overrides the generated URL)
- Ensure
boto3is installed in the environment. If not, install it. - Identify the source directory (e.g.,
slides/<ppt-name>/dist/) and the target S3 bucket name.
- Ensure the user has valid credentials in their environment:
-
Implementation:
- Create a Python script using
boto3to walk through the source directory. - Configure the S3 client with
endpoint_urlif provided, to support S3-compatible providers. - Upload each file, maintaining the relative path structure.
- Crucial: specific
ContentTypemust be set for each file based on its extension (e.g.,text/htmlfor.html,text/cssfor.css,image/pngfor.png) so that the browser renders it correctly. - Make the objects public if the bucket policy allows or requires ACL (optional, based on bucket configuration).
- Print the final website URL.
- Create a Python script using
Usage
Use the bundled script to upload files:
# Explicit bucket name
uv run {baseDir}/scripts/upload_to_s3.py "slides/my-presentation/dist" "my-bucket" --prefix "presentations/my-presentation"
# Using S3_BUCKET from environment
uv run {baseDir}/scripts/upload_to_s3.py "slides/my-presentation/dist" --prefix "presentations/my-presentation"
Usage Guidelines
- Bucket Name: Check if
S3_BUCKETis set in environment. If not, ask the user for the S3 Bucket name. - Endpoint URL: Check if the user is using a non-AWS provider (like MinIO or Aliyun). If so, request or verify the
endpoint_url. - Source Path: Default to looking for
distfolders inslides/if not specified.
Overview
Uploads a local static directory (e.g., slides) to AWS S3 or any S3-compatible object storage (MinIO, Aliyun OSS, Tencent COS) for public hosting. It preserves the directory structure and ensures each file gets the correct ContentType so browsers render content properly. Use this skill to publish or deploy generated content to the cloud with a public URL.
How This Skill Works
A Python script uses boto3 to traverse the source directory and upload files to the target bucket. It configures the client with endpoint_url for non-AWS providers and supports addressing styles and signature versions as needed. Each upload sets ContentType by file extension and makes the object public if allowed; the script prints the final public URL.
When to Use It
- Publishing a generated slides directory to a cloud bucket for public access
- Deploying a static site to AWS S3 or a compatible service for hosting
- Using a non-AWS provider (MinIO, Aliyun OSS, Tencent COS) with a custom endpoint
- Automating cloud deployment in a CI or local workflow
- Replacing a manual upload step with an upload-to-S3 script
Quick Start
- Step 1: Set credentials and endpoint in your environment (S3_ACCESS_KEY_ID, S3_SECRET_ACCESS_KEY, S3_BUCKET, and S3_ENDPOINT_URL if needed).
- Step 2: Prepare the source directory (e.g., slides/<name>/dist) and decide a prefix for the objects.
- Step 3: Run the upload script, e.g. uv run {baseDir}/scripts/upload_to_s3.py "slides/my-presentation/dist" --prefix "presentations/my-presentation" (or specify the bucket explicitly)
Best Practices
- Provide credentials and bucket details via environment variables or arguments (S3_ACCESS_KEY_ID, S3_SECRET_ACCESS_KEY, S3_BUCKET).
- Always set ContentType based on file extension to ensure correct rendering in browsers.
- Prefer a public-read ACL or a bucket policy that allows public access, if hosting publicly.
- Use endpoint_url for S3-compatible providers and configure addressingStyle (virtual for Aliyun) and signatureVersion as needed.
- After upload, verify the final URL and test accessibility of the hosted site.
Example Use Cases
- Upload slides/my-presentation/dist to a bucket and publish under presentations/my-presentation with a custom domain
- Deploy a static site to MinIO using a specific endpoint URL and verify public access
- Publish assets to Aliyun OSS with virtual addressing and a CDN-friendly URL
- Host a static site on Tencent COS by supplying endpoint URL and public-read permissions
- Automate uploads in CI by exporting S3 credentials and running uv run on the upload_to_s3.py script