Alibaba Cloud OSS platform adapter for moon-file-storage
async test "能力位报 false 的那一族就地拒绝;预签名是本地算出来的,一条请求都不发" {
let transport : &@transport.Transport = @transport.AsyncHttpTransport::new()
let client = @osssdk.Client::new(
@ossconfig.Config::new(
"https://oss-cn-zhangjiakou.example.invalid",
"cn-zhangjiakou",
@ossauth.Credentials::new("ak", "sk"),
),
transport,
)
let platform = @oss.OssPlatform::new(@oss.OssPlatformConfig::{
platform: "oss",
bucket: "demo-bucket",
domain: Some("https://demo-bucket.oss-cn-zhangjiakou.example.invalid"),
client,
})
let caps = platform.capabilities()
assert_true(caps.multipart_upload)
assert_true(caps.presigned_url)
assert_true(caps.metadata)
// 能力位由实测决定:写 public-read 被桶侧拒 403 AccessDenied,读回的 grant 是 default
assert_true(!caps.acl)
let intent = @model.FileInfo::draft("oss", "", "note", "txt")
let info = intent.stamped(@model.Stamp::{
platform: None,
path: Some("2026/10/note.txt"),
url: Some("https://demo-bucket.oss-cn-zhangjiakou.example.invalid/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-oss-signature=") is Some(_))
assert_true(url.find("2026/10/note.txt") is Some(_))
let refused = try {
platform.set_file_acl(info, @model.CannedAcl::PublicRead)
"no-error"
} catch {
@model.StorageError::NotSupported(reason) => "NotSupported:" + reason
_ => "other"
}
assert_true(refused.has_prefix("NotSupported:"))
}moon add mldong/moon-file-storage-ossInstall
Download zipAlibaba Cloud OSS platform adapter for moon-file-storage