Skip to content

Commit 5a861df

Browse files
grdsdevclaude
andcommitted
refactor(storage): replace explicit upload/update variants with UploadMethod enum
Remove uploadMultipart, uploadResumable, updateMultipart, updateResumable and consolidate into a method: UploadMethod parameter on upload() and update(). UploadMethod has three cases: - .auto (default) — picks multipart for ≤6 MB, TUS for larger - .multipart — always use a single multipart HTTP request - .resumable — always use the TUS resumable protocol update() now delegates to upload() internally, eliminating duplicated logic. The private HTTP helper is renamed from uploadMultipart to _performMultipartRequest to avoid confusion with the public API. Updates docs, tests, and the FileUploadView example (adds method picker). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent e0a9528 commit 5a861df

8 files changed

Lines changed: 156 additions & 351 deletions

File tree

Examples/Examples/Storage/FileUploadView.swift

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ struct FileUploadView: View {
2424
@State private var error: Error?
2525
@State private var upsertEnabled = false
2626
@State private var cacheControl = "3600"
27+
@State private var uploadMethod: UploadMethod = .auto
2728

2829
var body: some View {
2930
List {
@@ -59,6 +60,12 @@ struct FileUploadView: View {
5960
.keyboardType(.numberPad)
6061
.multilineTextAlignment(.trailing)
6162
}
63+
64+
Picker("Upload Method", selection: $uploadMethod) {
65+
Text("Auto (size-based)").tag(UploadMethod.auto)
66+
Text("Multipart").tag(UploadMethod.multipart)
67+
Text("Resumable (TUS)").tag(UploadMethod.resumable)
68+
}
6269
}
6370

6471
Section("Upload from Photo Library") {
@@ -197,7 +204,7 @@ struct FileUploadView: View {
197204

198205
let response = try await supabase.storage
199206
.from(selectedBucket)
200-
.upload(filePath, data: imageData, options: options).value
207+
.upload(filePath, data: imageData, options: options, method: uploadMethod).value
201208

202209
uploadedPath = response.path
203210
uploadProgress = 1.0
@@ -235,7 +242,7 @@ struct FileUploadView: View {
235242

236243
let response = try await supabase.storage
237244
.from(selectedBucket)
238-
.upload(filePath, fileURL: selectedDocument, options: options).value
245+
.upload(filePath, fileURL: selectedDocument, options: options, method: uploadMethod).value
239246

240247
uploadedPath = response.path
241248
uploadProgress = 1.0
@@ -277,7 +284,7 @@ struct FileUploadView: View {
277284

278285
let response = try await supabase.storage
279286
.from(selectedBucket)
280-
.upload(filePath, data: data, options: options).value
287+
.upload(filePath, data: data, options: options, method: uploadMethod).value
281288

282289
uploadedPath = response.path
283290
uploadProgress = 1.0

0 commit comments

Comments
 (0)