<BlockSwitcher>

<Block name="Async/Await">

```swift
func uploadData() async throws {
    let dataString = "Example file contents"
    let data = Data(dataString.utf8)
    let uploadTask = Amplify.Storage.uploadData(
        key: "ExampleKey",
        data: data
    )
    Task {
        for await progress in await uploadTask.progress {
            print("Progress: \(progress)")
        }
    }
    let value = try await uploadTask.value
    print("Completed: \(value)")
}
```

</Block>

<Block name="Combine">

```swift
// In your type's instance variables
var resultSink: AnyCancellable?
var progressSink: AnyCancellable?

// ...

func uploadData() {
    let dataString = "Example file contents"
    let data = Data(dataString.utf8)
    let uploadTask = Amplify.Storage.uploadData(
        key: "ExampleKey",
        data: data
    )
    progressSink = uploadTask
        .inProcessPublisher
        .sink { progress in
            print("Progress: \(progress)")
        }

    resultSink = uploadTask
        .resultPublisher
        .sink {
            if case let .failure(storageError) = $0 {
                print("Failed: \(storageError.errorDescription). \(storageError.recoverySuggestion)")
            }
        }
        receiveValue: { data in
            print("Completed: \(data)")
        }
}
```

</Block>

</BlockSwitcher>
