S3 platform adapter for moon-file-storage
async test "预签名是本地算出来的,不发出请求也能给出可核验的 URL" {
let client = @sdk.Client::new(
@sdk.Config::new(
"https://s3.example.invalid",
"us-east-1",
@sigv4.Credentials::new("ak", "sk"),
),
@transport.AsyncHttpTransport::new(),
)
let platform = @s3.S3Platform::new(@s3.S3PlatformConfig::{
platform: "s3-2",
bucket: "demo-bucket",
base_path: "",
supports_acl: false,
domain: Some("https://cdn.example.invalid/demo-bucket"),
client,
})
let caps = platform.capabilities()
assert_true(caps.multipart_upload)
assert_true(caps.presigned_url)
// 能力位由端点声明:MinIO 那两台的 canned ACL 写入不做,就在这里关掉。
assert_true(!caps.acl)
let intent = @model.FileInfo::draft("s3-2", "", "note", "txt")
let info = intent.stamped(@model.Stamp::{
platform: None,
path: Some("2026/10/note.txt"),
url: Some("https://cdn.example.invalid/demo-bucket/2026/10/note.txt"),
size: None,
create_time: None,
upload_id: None,
upload_status: None,
user_metadata: None,
})
let url = platform.presigned_url(info, @model.PresignMethod::Get, 120) catch {
_ => fail("presigned_url raised on a storage that claims the family")
}
assert_true(url.find("X-Amz-Signature=") is Some(_))
assert_true(url.find("2026/10/note.txt") is Some(_))
}moon add mldong/moon-file-storage-s3Install
Download zipS3 platform adapter for moon-file-storage