Skip to content

Commit cf994f6

Browse files
committed
Listing all swift options for all APIs
1 parent 67740f5 commit cf994f6

File tree

4 files changed

+99
-99
lines changed

4 files changed

+99
-99
lines changed

src/pages/[platform]/build-a-backend/storage/download-files/index.mdx

Lines changed: 87 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -273,12 +273,12 @@ let url = try await Amplify.Storage.getURL(
273273
)
274274
```
275275

276-
### More `getURL` options
276+
### All `getURL` options
277277

278278
Option | Type | Description |
279279
| -- | -- | ----------- |
280-
| expires | Integer | Number of seconds before the URL expires |
281-
| bucket | StorageBucket | The bucket in which the file is stored |
280+
| expires | Int | Number of seconds before the URL expires |
281+
| bucket | StorageBucket | The bucket in which the object is stored |
282282

283283
</InlineFilter>
284284

@@ -304,9 +304,8 @@ Future<void> getDownloadUrl() async {
304304

305305
</InlineFilter>
306306

307-
## Download to a file
308-
309307
<InlineFilter filters={["react", "angular", "javascript", "vue", "nextjs", "react-native"]}>
308+
## Download to a file
310309

311310
Use the `downloadData` API to download the file locally.
312311

@@ -321,6 +320,7 @@ const { body, eTag } = await downloadData({
321320
</InlineFilter>
322321

323322
<InlineFilter filters={["android"]}>
323+
## Download to a file
324324

325325
Use the `downloadFile` API to download the file locally on the client.
326326

@@ -386,6 +386,8 @@ download
386386
</InlineFilter>
387387

388388
<InlineFilter filters={["swift"]}>
389+
## Download files
390+
### Download to a local file
389391

390392
Use the `downloadFile` API to download the file locally on the client.
391393

@@ -446,6 +448,57 @@ let resultSink = downloadTask
446448
</Block>
447449
</BlockSwitcher>
448450

451+
### Download to data in memory
452+
453+
You can download to in-memory buffer [Data](https://developer.apple.com/documentation/foundation/data) object with `Amplify.Storage.downloadData`:
454+
455+
<BlockSwitcher>
456+
457+
<Block name="Async/Await">
458+
459+
```swift
460+
let downloadTask = Amplify.Storage.downloadData(
461+
path: .fromString("public/example/path")
462+
)
463+
Task {
464+
for await progress in await downloadTask.progress {
465+
print("Progress: \(progress)")
466+
}
467+
}
468+
let data = try await downloadTask.value
469+
print("Completed: \(data)")
470+
```
471+
472+
</Block>
473+
474+
<Block name="Combine">
475+
476+
```swift
477+
let downloadTask = Amplify.Storage.downloadData(
478+
path: .fromString("public/example/path")
479+
)
480+
let progressSink = downloadTask
481+
.inProcessPublisher
482+
.sink { progress in
483+
print("Progress: \(progress)")
484+
}
485+
486+
let resultSink = downloadTask
487+
.resultPublisher
488+
.sink {
489+
if case let .failure(storageError) = $0 {
490+
print("Failed: \(storageError.errorDescription). \(storageError.recoverySuggestion)")
491+
}
492+
}
493+
receiveValue: { data in
494+
print("Completed: \(data)")
495+
}
496+
```
497+
498+
</Block>
499+
500+
</BlockSwitcher>
501+
449502
### Download from a specified bucket
450503

451504
You can also perform a download operation from a specific bucket by providing the `bucket` option
@@ -455,20 +508,30 @@ You can also perform a download operation from a specific bucket by providing th
455508
You can use `.fromOutputs(name:)` to provide a string representing the target bucket's assigned name in the Amplify Backend.
456509

457510
```swift
511+
// Download to File
458512
let downloadTask = Amplify.Storage.downloadFile(
459513
path: .fromString("public/example/path"),
460514
local: downloadToFileUrl,
461515
options: .init(
462516
bucket: .fromOutputs(name: "secondBucket")
463517
)
464518
)
519+
520+
// Download to Data
521+
let downloadTask = Amplify.Storage.downloadData(
522+
path: .fromString("public/example/path"),
523+
options: .init(
524+
bucket: .fromOutputs(name: "secondBucket")
525+
)
526+
)
465527
```
466528
</Block>
467529

468530
<Block name="From Bucket Info">
469531
You can also use `.fromBucketInfo(_:)` to provide a bucket name and region directly.
470532

471533
```swift
534+
// Download to File
472535
let downloadTask = Amplify.Storage.downloadFile(
473536
path: .fromString("public/example/path"),
474537
local: downloadToFileUrl,
@@ -479,13 +542,25 @@ let downloadTask = Amplify.Storage.downloadFile(
479542
)
480543
)
481544
)
545+
546+
// Download to Data
547+
let downloadTask = Amplify.Storage.downloadData(
548+
path: .fromString("public/example/path"),
549+
options: .init(
550+
bucket: .fromBucketInfo(.init(
551+
bucketName: "another-bucket-name",
552+
region: "another-bucket-region")
553+
)
554+
)
555+
)
482556
```
483557
</Block>
484558
</BlockSwitcher>
485559

486560
</InlineFilter>
487561

488562
<InlineFilter filters={["flutter"]}>
563+
## Download to a file
489564

490565
You can download a file to a local directory using `Amplify.Storage.downloadFile`.
491566

@@ -563,61 +638,6 @@ try {
563638
```
564639
</InlineFilter>
565640

566-
<InlineFilter filters={["swift"]}>
567-
568-
## Download to data in memory
569-
570-
You can download to in-memory buffer [Data](https://developer.apple.com/documentation/foundation/data) object with `Amplify.Storage.downloadData`:
571-
572-
<BlockSwitcher>
573-
574-
<Block name="Async/Await">
575-
576-
```swift
577-
let downloadTask = Amplify.Storage.downloadData(
578-
path: .fromString("public/example/path")
579-
)
580-
Task {
581-
for await progress in await downloadTask.progress {
582-
print("Progress: \(progress)")
583-
}
584-
}
585-
let data = try await downloadTask.value
586-
print("Completed: \(data)")
587-
```
588-
589-
</Block>
590-
591-
<Block name="Combine">
592-
593-
```swift
594-
let downloadTask = Amplify.Storage.downloadData(
595-
path: .fromString("public/example/path")
596-
)
597-
let progressSink = downloadTask
598-
.inProcessPublisher
599-
.sink { progress in
600-
print("Progress: \(progress)")
601-
}
602-
603-
let resultSink = downloadTask
604-
.resultPublisher
605-
.sink {
606-
if case let .failure(storageError) = $0 {
607-
print("Failed: \(storageError.errorDescription). \(storageError.recoverySuggestion)")
608-
}
609-
}
610-
receiveValue: { data in
611-
print("Completed: \(data)")
612-
}
613-
```
614-
615-
</Block>
616-
617-
</BlockSwitcher>
618-
619-
</InlineFilter>
620-
621641
<InlineFilter filters={["react", "angular", "javascript", "vue", "nextjs", "react-native"]}>
622642

623643
### Download from a specified bucket
@@ -1118,42 +1138,7 @@ final operation = Amplify.Storage.downloadData(
11181138

11191139
<InlineFilter filters={["swift"]}>
11201140

1121-
### Download from a specified bucket
1122-
1123-
You can also perform a download operation from a specific bucket by providing the `bucket` option
1124-
1125-
<BlockSwitcher>
1126-
<Block name="From Outputs">
1127-
You can use `.fromOutputs(name:)` to provide a string representing the target bucket's assigned name in the Amplify Backend.
1128-
1129-
```swift
1130-
let downloadTask = Amplify.Storage.downloadData(
1131-
path: .fromString("public/example/path"),
1132-
options: .init(
1133-
bucket: .fromOutputs(name: "secondBucket")
1134-
)
1135-
)
1136-
```
1137-
</Block>
1138-
1139-
<Block name="From Bucket Info">
1140-
You can also use `.fromBucketInfo(_:)` to provide a bucket name and region directly.
1141-
1142-
```swift
1143-
let downloadTask = Amplify.Storage.downloadData(
1144-
path: .fromString("public/example/path"),
1145-
options: .init(
1146-
bucket: .fromBucketInfo(.init(
1147-
bucketName: "another-bucket-name",
1148-
region: "another-bucket-region")
1149-
)
1150-
)
1151-
)
1152-
```
1153-
</Block>
1154-
</BlockSwitcher>
1155-
1156-
## Pause, resume, and cancel downloads
1141+
### Pause, resume, and cancel downloads
11571142

11581143
Calls to `downloadData` or `downloadFile` return a reference to the task that is actually performing the download.
11591144

@@ -1171,6 +1156,12 @@ Download tasks are run using `URLSessionTask` instances internally. You can lear
11711156

11721157
</Callout>
11731158

1159+
### All `download` options
1160+
1161+
| Option | Type | Description |
1162+
| --- | --- | --- |
1163+
| bucket | StorageBucket | The bucket in which the object should be stored |
1164+
11741165
</InlineFilter>
11751166

11761167
<InlineFilter filters={["react", "angular", "javascript", "vue", "nextjs", "react-native"]}>

src/pages/[platform]/build-a-backend/storage/list-files/index.mdx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -938,11 +938,13 @@ receiveValue: { listResult in
938938
939939
</BlockSwitcher>
940940
941-
### More `list` options
941+
### All `list` options
942942
943943
| Option | Type | Description |
944944
| --- | --- | --- |
945+
| subpathStrategy | SubpathStrategy | The strategy to use when listing contents from subpaths |
945946
| pageSize | UInt | Number between 1 and 1,000 that indicates the limit of how many entries to fetch when retrieving file lists from the server |
947+
| bucket | StorageBucket | The bucket in which the objects are stored |
946948
| nextToken | String | String indicating the page offset at which to resume a listing. |
947949
948950

src/pages/[platform]/build-a-backend/storage/remove-files/index.mdx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,12 @@ let removedObject = try await Amplify.Storage.remove(
337337
</Block>
338338
</BlockSwitcher>
339339

340+
### All `remove` options
341+
342+
Option | Type | Description |
343+
| -- | -- | ----------- |
344+
| bucket | StorageBucket | The bucket in which the object is stored |
345+
340346
</InlineFilter>
341347

342348
<InlineFilter filters={["flutter"]}>

src/pages/[platform]/build-a-backend/storage/upload-files/index.mdx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1462,12 +1462,13 @@ Upload tasks are run using `URLSessionTask` instances internally. You can learn
14621462

14631463
<InlineFilter filters={["swift"]}>
14641464

1465-
## More upload options
1465+
### All `upload` options
14661466

14671467
Option | Type | Description |
14681468
| -- | -- | ----------- |
1469-
| metadata | Dictionary | Metadata for the object to store. |
1469+
| metadata | [String: String] | Metadata for the object to store. |
14701470
| contentType | String | The standard MIME type describing the format of the object to store. |
1471+
| bucket | StorageBucket | The bucket in which the object should be stored |
14711472

14721473
</InlineFilter>
14731474

0 commit comments

Comments
 (0)