Skip to content

Commit

Permalink
update storage path example
Browse files Browse the repository at this point in the history
  • Loading branch information
phantumcode committed Apr 22, 2024
1 parent d1598db commit 8abfd81
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 17 deletions.
12 changes: 6 additions & 6 deletions src/fragments/lib/storage/ios/download.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ You can download to in-memory buffer [Data](https://developer.apple.com/document
<Block name="Async/Await">

```swift
let downloadTask = Amplify.Storage.downloadData(path: .fromString("example/path"))
let downloadTask = Amplify.Storage.downloadData(path: .fromString("public/example/path"))
Task {
for await progress in await downloadTask.progress {
print("Progress: \(progress)")
Expand All @@ -25,7 +25,7 @@ print("Completed: \(data)")
<Block name="Combine">

```swift
let downloadTask = Amplify.Storage.downloadData(path: .fromString("example/path"))
let downloadTask = Amplify.Storage.downloadData(path: .fromString("public/example/path"))
let progressSink = downloadTask
.inProcessPublisher
.sink { progress in
Expand Down Expand Up @@ -108,7 +108,7 @@ let downloadToFileName = FileManager.default.urls(
)[0].appendingPathComponent("myFile.txt")

let downloadTask = Amplify.Storage.downloadFile(
path: .fromString("example/path"),
path: .fromString("public/example/path"),
local: downloadToFileName,
options: nil
)
Expand All @@ -132,7 +132,7 @@ let downloadToFileName = FileManager.default.urls(
)[0].appendingPathComponent("myFile.txt")

let downloadTask = Amplify.Storage.downloadFile(
path: .fromString("example/path"),
path: .fromString("public/example/path"),
local: downloadToFileName,
options: nil
)
Expand Down Expand Up @@ -226,7 +226,7 @@ You can also retrieve a URL for the object in storage:
<BlockSwitcher>
<Block name="With StoragePath">
```swift
let url = try await Amplify.Storage.getURL(path: .fromString("example/path"))
let url = try await Amplify.Storage.getURL(path: .fromString("public/example/path"))
print("Completed: \(url)")
```
</Block>
Expand All @@ -248,7 +248,7 @@ that object.
<Block name="With StoragePath">
```swift
let url = try await Amplify.Storage.getURL(
path: .fromString("example/path"),
path: .fromString("public/example/path"),
options: .init(
pluginOptions: AWSStorageGetURLOptions(
validateObjectExistence: true
Expand Down
4 changes: 2 additions & 2 deletions src/fragments/lib/storage/ios/getting-started/40_upload.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ func uploadData() async throws {
let dataString = "Example file contents"
let data = Data(dataString.utf8)
let uploadTask = Amplify.Storage.uploadData(
path: .fromString("example/path"),
path: .fromString("public/example/path"),
data: data
)
Task {
Expand Down Expand Up @@ -36,7 +36,7 @@ func uploadData() {
let dataString = "Example file contents"
let data = Data(dataString.utf8)
let uploadTask = Amplify.Storage.uploadData(
path: .fromString("example/path"),
path: .fromString("public/example/path"),
data: data
)
progressSink = uploadTask
Expand Down
4 changes: 2 additions & 2 deletions src/fragments/lib/storage/ios/list.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ You can list all of the objects uploaded under a given prefix by setting the `pa
```swift
let options = StorageListRequest.Options(pageSize: 1000)
let listResult = try await Amplify.Storage.list(
path: .fromString("example/path"),
path: .fromString("public/example/path"),
options: options
)
listResult.items.forEach { item in
Expand All @@ -24,7 +24,7 @@ listResult.items.forEach { item in
let sink = Amplify.Publisher.create {
let options = StorageListRequest.Options(pageSize: 1000)
try await Amplify.Storage.list(
path: .fromString("example/path"),
path: .fromString("public/example/path"),
options: options
)
}.sink {
Expand Down
4 changes: 2 additions & 2 deletions src/fragments/lib/storage/ios/remove.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Delete an object uploaded to S3 by using `Amplify.Storage.remove`:
<Block name="Async/Await">

```swift
let removedObject = try await Amplify.Storage.remove(path: .fromString("example/path"))
let removedObject = try await Amplify.Storage.remove(path: .fromString("public/example/path"))
print("Deleted \(removedObject)")
```

Expand All @@ -16,7 +16,7 @@ print("Deleted \(removedObject)")

```swift
let sink = Amplify.Publisher.create {
try await Amplify.Storage.remove(path: .fromString("example/path"))
try await Amplify.Storage.remove(path: .fromString("public/example/path"))
}.sink {
if case let .failure(error) = $0 {
print("Failed: \(error)")
Expand Down
8 changes: 4 additions & 4 deletions src/fragments/lib/storage/ios/upload.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ To upload to S3 from a data object, specify the `path` and the `data` object to
let dataString = "My Data"
let data = Data(dataString.utf8)
let uploadTask = Amplify.Storage.uploadData(
path: .fromString("example/path"),
path: .fromString("public/example/path"),
data: data
)
Task {
Expand All @@ -30,7 +30,7 @@ print("Completed: \(value)")
let dataString = "My Data"
let data = Data(dataString.utf8)
let uploadTask = Amplify.Storage.uploadData(
path: .fromString("example/path"),
path: .fromString("public/example/path"),
data: data
)
let progressSink = uploadTask
Expand Down Expand Up @@ -133,7 +133,7 @@ try dataString.write(
)

let uploadTask = Amplify.Storage.uploadFile(
path: .fromString("example/path/myFile.txt"),
path: .fromString("public/example/path/myFile.txt"),
local: filename
)

Expand Down Expand Up @@ -167,7 +167,7 @@ try dataString.write(
)

let uploadTask = Amplify.Storage.uploadFile(
path: .fromString("example/path/myFile.txt"),
path: .fromString("public/example/path/myFile.txt"),
local: filename
)
progressSink = uploadTask
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ For example, to upload a file using transfer acceleration:
<Block name="With StoragePath">
```swift
let uploadTask = Amplify.Storage.uploadFile(
path: .fromString("example/key"),
path: .fromString("public/example/key"),
local: aLocalFile,
options: .init(
pluginOptions: [
Expand Down

0 comments on commit 8abfd81

Please sign in to comment.