feat: add post3 s3 proxy for postgresql

Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
2026-02-27 11:37:48 +01:00
commit 21bac4a33f
67 changed files with 14403 additions and 0 deletions

View File

@@ -0,0 +1,76 @@
//! Basic post3 usage: create a bucket, put/get/delete objects, list objects.
//!
//! Prerequisites: post3-server running on localhost:9000
//! mise run up && mise run dev
//!
//! Run:
//! cargo run -p post3-sdk --example basic
use post3_sdk::Post3Client;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let endpoint = std::env::var("POST3_ENDPOINT")
.unwrap_or_else(|_| "http://localhost:9000".to_string());
let client = Post3Client::new(&endpoint);
// Create a bucket
println!("Creating bucket 'example-bucket'...");
client.create_bucket("example-bucket").await?;
// List buckets
let buckets = client.list_buckets().await?;
println!("Buckets: {:?}", buckets);
// Put an object
println!("Putting 'hello.txt'...");
client
.put_object("example-bucket", "hello.txt", b"Hello, post3!")
.await?;
// Get the object back
let data = client.get_object("example-bucket", "hello.txt").await?;
println!("Got: {}", String::from_utf8_lossy(&data));
// Put a few more objects
client
.put_object("example-bucket", "docs/readme.md", b"# README")
.await?;
client
.put_object("example-bucket", "docs/guide.md", b"# Guide")
.await?;
// List all objects
let objects = client.list_objects("example-bucket", None).await?;
println!("All objects:");
for obj in &objects {
println!(" {} ({} bytes)", obj.key, obj.size);
}
// List with prefix filter
let docs = client
.list_objects("example-bucket", Some("docs/"))
.await?;
println!("Objects under docs/:");
for obj in &docs {
println!(" {} ({} bytes)", obj.key, obj.size);
}
// Delete objects
println!("Cleaning up...");
client
.delete_object("example-bucket", "hello.txt")
.await?;
client
.delete_object("example-bucket", "docs/readme.md")
.await?;
client
.delete_object("example-bucket", "docs/guide.md")
.await?;
// Delete the bucket
client.delete_bucket("example-bucket").await?;
println!("Done!");
Ok(())
}