Skip to content

Commit 2d695c3

Browse files
authored
Update README.md
1 parent 82f0554 commit 2d695c3

File tree

1 file changed

+58
-1
lines changed

1 file changed

+58
-1
lines changed

README.md

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,4 +140,61 @@ Task {
140140
```
141141

142142
### Downloading Files
143-
<a id="downloading-files"></a>
143+
<a id="downloading"></a>
144+
145+
Using Escaping Closures Or Combine
146+
147+
```swift
148+
networkManager.downloadData(fromURL: url) { tempLocalUrl, response, error in
149+
if let tempLocalUrl = tempLocalUrl {
150+
// Get data from tempLocalUrl url
151+
} else if error = error {
152+
// Handle the error
153+
}
154+
}
155+
```
156+
157+
Using async-await
158+
159+
```swift
160+
Task {
161+
do {
162+
let fileURL = try await networkManager.downloadFile(using: .async)
163+
// Use the file
164+
} catch {
165+
// Handle the error
166+
}
167+
}
168+
```
169+
170+
### Uploading Data
171+
<a id="uploading"></a>
172+
173+
Using Escaping Closures Or Combine
174+
175+
```swift
176+
networkManager.uploadData(toURL: url, data: json, mimeType: .json) { response , error in
177+
if let error = error {
178+
// Handle the error
179+
} else {
180+
// Handle the response
181+
}
182+
}
183+
```
184+
185+
Using async-await
186+
187+
```swift
188+
Task {
189+
do {
190+
let returnedResponse = try await networkManager.uploadData(toURL: url, data: json, mimeType: .json)
191+
// Handle the response
192+
} catch {
193+
// Handle the error
194+
}
195+
}
196+
```
197+
198+
### Contribution
199+
<a id="contribution"></a>
200+
If you encounter any issues, feel free to open an issue. Contributions are also welcome, whether it's bug fixes, new features, or documentation improvements.

0 commit comments

Comments
 (0)