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:
ryan
2026-06-13 15:48:41 +08:00
parent ce9423f877
commit 1d37242a8b
9 changed files with 37 additions and 57 deletions
+3 -3
View File
@@ -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)