惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

月光博客
月光博客
Stack Overflow Blog
Stack Overflow Blog
L
LangChain Blog
Jina AI
Jina AI
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
雷峰网
雷峰网
T
Tailwind CSS Blog
MongoDB | Blog
MongoDB | Blog
博客园 - 【当耐特】
博客园 - 聂微东
V
Visual Studio Blog
博客园_首页
Engineering at Meta
Engineering at Meta
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
The Cloudflare Blog
人人都是产品经理
人人都是产品经理
Apple Machine Learning Research
Apple Machine Learning Research
阮一峰的网络日志
阮一峰的网络日志
Microsoft Security Blog
Microsoft Security Blog
GbyAI
GbyAI
F
Fortinet All Blogs
C
Check Point Blog
罗磊的独立博客
H
Hackread – Cybersecurity News, Data Breaches, AI and More

OneUptime Blog

How to Monitor Azure App Services (PaaS) with OpenTelemetry Grafana Stack vs OneUptime: DIY Observability or Unified Platform? Your AI Workloads Are About to Blow Up Your Observability Bill The Great Observability Consolidation Is Here How to Write Custom Object Classes for Ceph How to Write Custom Ceph Manager Modules How to Write a ceph.conf Configuration File How to Use Rook-Ceph with OpenShift How to Use Rook-Ceph with Longhorn for Comparison How to Configure Volume Snapshot Class for RBD in Rook How to Configure VolumeReplicationClass Scheduling Intervals in Rook How to Set Up Volume Replication with Rook-Ceph How to Create Volume Group Snapshots with Rook CSI How to Visualize Ceph Network Performance in Grafana How to Enable Virtual Host-Style Bucket Access in Rook How to View Runtime Configuration via Admin Socket How to View Quota Settings and Update Stats in Ceph RGW How to View PG Scaling Recommendations with autoscale-status How to View PG Distribution via Admin Socket How to View Performance Metrics in the Ceph Dashboard How to View OSD Performance Counters in Ceph How to View Connection Status via Admin Socket How to View Ceph Cluster Summary Dashboard via CLI How to Version Control Rook-Ceph Configuration How to Version Control Ceph Infrastructure with Terraform How to Verify Kubernetes Node Requirements for Rook-Ceph Deployment How to Verify Health Before and After Rook Upgrades How to Verify Data Integrity with Deep Scrubbing How to Verify Complete Rook-Ceph Cleanup How to Verify Backup Integrity from Ceph Snapshots
How to Use boto3 (Python) with Ceph RGW S3
Nawaz Dhandala · 2026-03-31 · via OneUptime Blog

Overview

boto3 is the official AWS SDK for Python. By passing a custom endpoint_url and disabling SSL for development, you can use it to interact with Ceph RGW exactly as you would with AWS S3. This makes it easy to write Python applications that work against your on-premises Ceph cluster.

Install boto3

pip install boto3

Create a boto3 Session for Ceph

import boto3
from botocore.client import Config

s3 = boto3.client(
    "s3",
    endpoint_url="http://rook-ceph-rgw-my-store.rook-ceph:80",
    aws_access_key_id="myaccesskey",
    aws_secret_access_key="mysecretkey",
    region_name="us-east-1",
    config=Config(signature_version="s3v4", s3={"addressing_style": "path"}),
)

Bucket Operations

Create a bucket:

s3.create_bucket(Bucket="my-python-bucket")

List all buckets:

response = s3.list_buckets()
for bucket in response["Buckets"]:
    print(bucket["Name"])

Delete a bucket (must be empty):

s3.delete_bucket(Bucket="my-python-bucket")

Object Operations

Upload a file:

s3.upload_file(
    Filename="/tmp/data.json",
    Bucket="my-python-bucket",
    Key="data/data.json",
)

Upload from memory:

import json

data = {"key": "value", "count": 42}
s3.put_object(
    Bucket="my-python-bucket",
    Key="config/settings.json",
    Body=json.dumps(data),
    ContentType="application/json",
)

Download a file:

s3.download_file(
    Bucket="my-python-bucket",
    Key="data/data.json",
    Filename="/tmp/downloaded.json",
)

List objects in a bucket:

paginator = s3.get_paginator("list_objects_v2")
for page in paginator.paginate(Bucket="my-python-bucket", Prefix="data/"):
    for obj in page.get("Contents", []):
        print(obj["Key"], obj["Size"])

Generate a Presigned URL

url = s3.generate_presigned_url(
    ClientMethod="get_object",
    Params={"Bucket": "my-python-bucket", "Key": "data/data.json"},
    ExpiresIn=3600,
)
print(url)

Copy Objects

s3.copy_object(
    CopySource={"Bucket": "my-python-bucket", "Key": "data/data.json"},
    Bucket="my-python-bucket",
    Key="backup/data.json",
)

Error Handling

from botocore.exceptions import ClientError

try:
    s3.head_object(Bucket="my-python-bucket", Key="nonexistent.txt")
except ClientError as e:
    if e.response["Error"]["Code"] == "404":
        print("Object does not exist")
    else:
        raise

Summary

boto3 works transparently with Ceph RGW by specifying a custom endpoint_url and path-style addressing. All standard S3 operations are supported, making it easy to build Python applications that run against both AWS S3 and on-premises Ceph with minimal configuration changes.