Skip to content

Commit 28239b1

Browse files
authored
Update REST API.md
1 parent 17e7a91 commit 28239b1

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

Documentation/REST API.md

+56
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Upload API
22

33
* [Initialization](#initialization)
4+
* [Get list of files](#get-list-of-files-api-reference)
45

56

67
### Initialization
@@ -9,3 +10,58 @@ REST API requires both public and secret key:
910
```swift
1011
let uploadcare = Uploadcare(withPublicKey: "YOUR_PUBLIC_KEY", secretKey: "YOUR_SECRET_KEY")
1112
```
13+
### Get list of files ([API Reference](https://uploadcare.com/api-refs/rest-api/v0.6.0/#operation/filesList?utm_source=github&utm_medium=referral&utm_campaign=uploadcare-swift)) ###
14+
15+
```swift
16+
// Make query object
17+
let query = PaginationQuery()
18+
.stored(true)
19+
.ordering(.sizeDESC)
20+
.limit(5)
21+
// Make files list object
22+
let filesList = uploadcare.list()
23+
24+
// Get files list
25+
filesList.get(withQuery: query) { (list, error) in
26+
if let error = error {
27+
print(error)
28+
return
29+
}
30+
31+
print(list ?? "")
32+
}
33+
```
34+
Get next page:
35+
```swift
36+
// check if next page is available
37+
guard filesList.next != nil else { return }
38+
// get next page
39+
filesList.nextPage { (list, error) in
40+
if let error = error {
41+
print(error)
42+
return
43+
}
44+
print(list ?? "")
45+
}
46+
```
47+
48+
Get previous page:
49+
```swift
50+
// check if previous page is available
51+
guard filesList.previous != nil else { return }
52+
// get next page
53+
filesList.previousPage { (list, error) in
54+
if let error = error {
55+
print(error)
56+
return
57+
}
58+
print(list ?? "")
59+
}
60+
```
61+
62+
63+
64+
65+
66+
67+

0 commit comments

Comments
 (0)