mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-10-11 17:56:37 +08:00
refactor(storage): update Backend.Put to return PutResult and encapsulate bucket mapping
- Update Backend.Put method signature in storage.go to return (PutResult, error). - Adjust all backend implementations (local, oss, s3, webdav) to return a PutResult enclosing Key and Bucket. - Refactor storeUploadFile in upload routers.go to extract key/bucket from PutResult, eliminating manual config bucket lookups. - Remove the unused cfgBucket helper from storage_ops.go. - Adjust storage_migration_task.go and tests to accommodate the updated method signature.
This commit is contained in:
@@ -19,12 +19,12 @@ func TestLocalBackendRoundTrip(t *testing.T) {
|
||||
const key = "uploads/2026/06/13/test.txt"
|
||||
const content = "wavelet storage"
|
||||
|
||||
storedKey, err := backend.Put(ctx, key, bytes.NewBufferString(content), int64(len(content)), "text/plain")
|
||||
storedResult, err := backend.Put(ctx, key, bytes.NewBufferString(content), int64(len(content)), "text/plain")
|
||||
if err != nil {
|
||||
t.Fatalf("Put(%q) returned error: %v", key, err)
|
||||
}
|
||||
if storedKey != key {
|
||||
t.Errorf("Put(%q) key = %q, want %q", key, storedKey, key)
|
||||
if storedResult.Key != key {
|
||||
t.Errorf("Put(%q) key = %q, want %q", key, storedResult.Key, key)
|
||||
}
|
||||
|
||||
object, err := backend.Get(ctx, key)
|
||||
|
||||
Reference in New Issue
Block a user