Qiniu Kodo platform adapter for moon-file-storage
test "预签名两档:GET 签得出私有 URL,PUT 按参照实现响亮拒绝" {
let transport = @transport.AsyncHttpTransport::new()
let auth = @kodoauth.Auth::new("ak-example", "sk-example")
let region = match @kodoconfig.Region::with_region_id("z0") {
None => fail("z0 is always constructible")
Some(one) => one
}
let client = @kodo.Client::new(
transport,
auth,
@kodoconfig.Config::new(region, use_https=true),
"demo-bucket",
) catch {
_ => fail("a non-empty bucket name always constructs")
}
let platform = @qiniu.QiniuPlatform::new(@qiniu.QiniuPlatformConfig::new(
"qiniu",
client,
transport,
domain=Some("https://cdn.example.invalid"),
))
let caps = platform.capabilities()
assert_true(caps.multipart_upload)
assert_true(caps.presigned_url)
assert_true(caps.metadata)
// 七牛没有 canned ACL 这一族:报 false,被调用就抛,不接受请求后什么都不做
assert_true(!caps.acl)
let info = @model.FileInfo::draft("qiniu", "2026/10", "note.txt", "txt")
.stamped(@model.Stamp::{
platform: None,
path: Some("2026/10/note.txt"),
url: None,
size: None,
create_time: None,
upload_id: None,
upload_status: None,
user_metadata: None,
})
let url = platform.presigned_url(info, @model.PresignMethod::Get, 120)
assert_true(url.has_prefix("https://cdn.example.invalid/2026/10/note.txt?e="))
assert_true(url.contains("&token=ak-example:"))
let refused = platform.presigned_url(info, @model.PresignMethod::Put, 120) catch {
@model.StorageError::NotSupported(reason) => "NotSupported:" + reason
_ => "other"
}
assert_true(refused.has_prefix("NotSupported:"))
}moon add mldong/moon-file-storage-qiniuInstall
Download zipQiniu Kodo platform adapter for moon-file-storage