Skip to content

Commit 43b6a3b

Browse files
rsedykhmakoni
andauthored
Storing examples update (#110)
* Default to store: .auto in examples * Change store to doNotStore in tests * test fixed --------- Co-authored-by: Sergei Armodin <dolph-in@yandex.ru>
1 parent 8186c92 commit 43b6a3b

File tree

8 files changed

+24
-24
lines changed

8 files changed

+24
-24
lines changed

Demo/Demo/Modules/FilesListStore.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ class FilesListStore: ObservableObject {
121121
}
122122
}
123123

124-
self.currentTask = self.uploadcare?.uploadFile(data, withName: filename, store: .doNotStore, onProgress, { result in
124+
self.currentTask = self.uploadcare?.uploadFile(data, withName: filename, store: .auto, onProgress, { result in
125125
switch result {
126126
case .failure(let error):
127127
DLog(error)

Documentation/Upload API.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,12 @@ guard let url = Bundle.main.url(forResource: "Mona_Lisa_23mb", withExtension: "j
5959
guard let data = try? Data(contentsOf: url) else { return }
6060

6161
// Async:
62-
let file = try await uploadcare.uploadFile(data, withName: "random_file_name.jpg", store: .doNotStore) { progress in
62+
let file = try await uploadcare.uploadFile(data, withName: "random_file_name.jpg", store: .auto) { progress in
6363
print("progress: \(progress)")
6464
}
6565

6666
// With a completion callback:
67-
let task = uploadcare.uploadFile(data, withName: "some_file.ext", store: .doNotStore, metadata: ["someKey": "someMetaValue"]) { progress in
67+
let task = uploadcare.uploadFile(data, withName: "some_file.ext", store: .auto, metadata: ["someKey": "someMetaValue"]) { progress in
6868
print("progress: \(progress)")
6969
} _: { result in
7070
switch result {
@@ -90,12 +90,12 @@ You can also create a file object (alternative syntax):
9090
// Async:
9191
var fileForUploading = uploadcare.file(withContentsOf: url)!
9292
fileForUploadingfileForUploading.metadata = ["myKey": "myValue"]
93-
let file = try await fileForUploading.upload(withName: "random_file_name.jpg", store: .doNotStore)
93+
let file = try await fileForUploading.upload(withName: "random_file_name.jpg", store: .auto)
9494

9595
// With a completion callback. Progress and completion callbacks are optional:
9696
var fileForUploading2 = uploadcare.file(withContentsOf: url)!
9797
fileForUploading2.metadata = ["myKey": "myValue"]
98-
fileForUploading2.upload(withName: "my_file.jpg", store: .store)
98+
fileForUploading2.upload(withName: "my_file.jpg", store: .auto)
9999
```
100100

101101
Sometimes you don't want to have the secret key in your client app and want to get it from the backend. In that case, you can provide an upload signature directly:
@@ -104,10 +104,10 @@ Sometimes you don't want to have the secret key in your client app and want to g
104104
let signature = UploadSignature(signature: "signature", expire: 1658486910)
105105

106106
// Async:
107-
let file = try await uploadcare.uploadFile(data, withName: "random_file_name.jpg", store: .doNotStore, uploadSignature: signature)
107+
let file = try await uploadcare.uploadFile(data, withName: "random_file_name.jpg", store: .auto, uploadSignature: signature)
108108

109109
// With a completion callback:
110-
let task = uploadcare.uploadFile(data, withName: "some_file.ext", store: .doNotStore, uploadSignature: signature) { progress in
110+
let task = uploadcare.uploadFile(data, withName: "some_file.ext", store: .auto, uploadSignature: signature) { progress in
111111
print("progress: \(progress)")
112112
} _: { result in
113113
...
@@ -122,7 +122,7 @@ Direct uploads work with background `URLSession`, so uploading will continue if
122122
guard let url = URL(string: "https://source.unsplash.com/featured"),
123123
let data = try? Data(contentsOf: url) else { return }
124124

125-
let task = uploadcare.uploadAPI.directUpload(files: ["random_file_name.jpg": data], store: .store, metadata: ["someKey": "someMetaValue"]) { progress in
125+
let task = uploadcare.uploadAPI.directUpload(files: ["random_file_name.jpg": data], store: .auto, metadata: ["someKey": "someMetaValue"]) { progress in
126126
print("upload progress: \(progress * 100)%")
127127
} _: { result in
128128
switch result {
@@ -146,7 +146,7 @@ guard let url = URL(string: "https://source.unsplash.com/featured"),
146146
let data = try? Data(contentsOf: url) else { return }
147147

148148
let signature = UploadSignature(signature: "signature", expire: 1658486910)
149-
let task = uploadcare.uploadAPI.directUpload(files: ["random_file_name.jpg": data], store: .store, uploadSignature: signature) { progress in
149+
let task = uploadcare.uploadAPI.directUpload(files: ["random_file_name.jpg": data], store: .auto, uploadSignature: signature) { progress in
150150
print("upload progress: \(progress * 100)%")
151151
} _: { result in
152152
/// ...
@@ -168,12 +168,12 @@ let data = try! Data(contentsOf: url)
168168
let metadata = ["someKey": "someMetaValue"]
169169

170170
// Async:
171-
let file = try await uploadcare.uploadAPI.multipartUpload(data, withName: "Mona_Lisa_big.jpg", store: .store, metadata: metadata) { progress in
171+
let file = try await uploadcare.uploadAPI.multipartUpload(data, withName: "Mona_Lisa_big.jpg", store: .auto, metadata: metadata) { progress in
172172
print("progress: \(progress)")
173173
}
174174

175175
// With a completion callback:
176-
let task = uploadcare.uploadAPI.multipartUpload(data, withName: "Mona_Lisa_big.jpg", store: .store, metadata: metadata) { progress in
176+
let task = uploadcare.uploadAPI.multipartUpload(data, withName: "Mona_Lisa_big.jpg", store: .auto, metadata: metadata) { progress in
177177
print("progress: \(progress)")
178178
} _: { result in
179179
switch result {

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,17 +123,17 @@ guard let data = try? Data(contentsOf: url) else { return }
123123
// You can create an UploadedFile object to operate with it
124124
var fileForUploading1 = uploadcare.file(fromData: data)
125125
fileForUploading2.metadata = ["myKey": "myValue"]
126-
try await fileForUploading1.upload(withName: "random_file_name.jpg", store: .store)
126+
try await fileForUploading1.upload(withName: "random_file_name.jpg", store: .auto)
127127

128128
// Or you can just upload data and provide a filename
129129

130130
var fileForUploading2 = uploadcare.file(withContentsOf: url)!
131-
let file = try await uploadcare.uploadFile(data, withName: "random_file_name.jpg", store: .doNotStore) { progress in
131+
let file = try await uploadcare.uploadFile(data, withName: "random_file_name.jpg", store: .auto) { progress in
132132
print("upload progress: \(progress * 100)%")
133133
}
134134

135135
// Same method with a completion callback that returns a task that can be paused or canceled:
136-
let task = uploadcare.uploadFile(data, withName: "random_file_name.jpg", store: .store, metadata: ["someKey": "someMetaValue"]) { progress in
136+
let task = uploadcare.uploadFile(data, withName: "random_file_name.jpg", store: .auto, metadata: ["someKey": "someMetaValue"]) { progress in
137137
print("upload progress: \(progress * 100)%")
138138
} _: { result in
139139
switch result {

Sources/Uploadcare/UploadAPI.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ extension UploadAPI {
486486
///
487487
/// let task = uploadcare.uploadAPI.directUpload(
488488
/// files: ["random_file_name.jpg": data],
489-
/// store: .doNotStore,
489+
/// store: .auto,
490490
/// metadata: metadata,
491491
/// onProgress
492492
/// ) { result in
@@ -683,7 +683,7 @@ extension UploadAPI {
683683
/// uploadcare.uploadAPI.multipartUpload(
684684
/// data,
685685
/// withName: "Mona_Lisa_23mb.jpg",
686-
/// store: .doNotStore,
686+
/// store: .auto,
687687
/// metadata: metadata,
688688
/// onProgress
689689
/// ) { result in
@@ -812,7 +812,7 @@ extension UploadAPI {
812812
/// let file = try await uploadcare.uploadAPI.multipartUpload(
813813
/// data,
814814
/// withName: "Mona_Lisa_23mb.jpg",
815-
/// store: .doNotStore,
815+
/// store: .auto,
816816
/// metadata: ["someKey": "someMetaValue"]
817817
/// ) { progress in
818818
/// print("Upload progress: \(progress)")

Sources/Uploadcare/Uploadcare.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2569,7 +2569,7 @@ extension Uploadcare {
25692569
/// guard let url = Bundle.main.url(forResource: "Mona_Lisa_23mb", withExtension: "jpg") else { return }
25702570
/// guard let data = try? Data(contentsOf: url) else { return }
25712571
///
2572-
/// let task = uploadcare.uploadFile(data, withName: "some_file.ext", store: .doNotStore, metadata: ["someKey": "someMetaValue"]) { progress in
2572+
/// let task = uploadcare.uploadFile(data, withName: "some_file.ext", store: .auto, metadata: ["someKey": "someMetaValue"]) { progress in
25732573
/// print("progress: \(progress)")
25742574
/// } _: { result in
25752575
/// switch result {
@@ -2691,7 +2691,7 @@ extension Uploadcare {
26912691
/// let file = try await uploadcare.uploadFile(
26922692
/// data,
26932693
/// withName: "random_file_name.jpg",
2694-
/// store: .doNotStore
2694+
/// store: .auto
26952695
/// ) { progress in
26962696
/// print("progress: \(progress)")
26972697
/// }

Sources/Uploadcare/models/upload/UploadedFile.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ public class UploadedFile: Codable {
207207
/// print("progress: \(progress)")
208208
/// }
209209
///
210-
/// let task = fileForUploading.upload(withName: "my_file.jpg", store: .store, onProgress, { result in
210+
/// let task = fileForUploading.upload(withName: "my_file.jpg", store: .auto, onProgress, { result in
211211
/// switch result {
212212
/// case .failure(let error):
213213
/// print(error.detail)
@@ -288,7 +288,7 @@ public class UploadedFile: Codable {
288288
///
289289
/// let uploadedFile = try await fileForUploading.upload(
290290
/// withName: "my_file.jpg",
291-
/// store: .store
291+
/// store: .auto
292292
/// )
293293
/// ```
294294
/// - Parameters:

Sources/UploadcareWidget/SelectSourceView.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ public struct SelectSourceView: View {
150150
let onProgress: (Double)->Void = { (progress) in
151151

152152
}
153-
self.api.uploadcare?.uploadAPI.directUpload(files: [filename: data], store: .store, onProgress, { result in
153+
self.api.uploadcare?.uploadAPI.directUpload(files: [filename: data], store: .auto, onProgress, { result in
154154
switch result {
155155
case .failure(let error):
156156
DLog(error)
@@ -171,7 +171,7 @@ public struct SelectSourceView: View {
171171
return
172172
}
173173

174-
fileForUploading.upload(withName: filename, store: .store, onProgress, { result in
174+
fileForUploading.upload(withName: filename, store: .auto, onProgress, { result in
175175
switch result {
176176
case .failure(let error):
177177
DLog(error)

Tests/UploadcareTests/RESTAPIIntegrationAsyncTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ final class RESTAPIIntegrationAsyncTests: XCTestCase {
352352
// let file = uploadcare.file(fromData: data)
353353
// let name = UUID().uuidString
354354
//
355-
// storingTestTask = file.upload(withName: name, store: .store, uploadSignature: nil) { _ in
355+
// storingTestTask = file.upload(withName: name, store: .doNotStore, uploadSignature: nil) { _ in
356356
//
357357
// } _: { result in
358358
// switch result {

0 commit comments

Comments
 (0)