Skip to content

Commit f6126da

Browse files
committed
Add sending to async Storage APIs
1 parent 0d885d2 commit f6126da

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

FirebaseStorage/Sources/AsyncAwait.swift

+8-6
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public extension StorageReference {
2626
/// the task will be cancelled and an error will be thrown.
2727
/// - Throws: An error if the operation failed, for example if the data exceeded `maxSize`.
2828
/// - Returns: Data object.
29-
func data(maxSize: Int64) async throws -> Data {
29+
func data(maxSize: Int64) async throws -> sending Data {
3030
return try await withCheckedThrowingContinuation { continuation in
3131
_ = self.getData(maxSize: maxSize) { result in
3232
continuation.resume(with: result)
@@ -48,7 +48,8 @@ public extension StorageReference {
4848
/// - Returns: StorageMetadata with additional information about the object being uploaded.
4949
func putDataAsync(_ uploadData: Data,
5050
metadata: StorageMetadata? = nil,
51-
onProgress: ((Progress?) -> Void)? = nil) async throws -> StorageMetadata {
51+
onProgress: ((Progress?) -> Void)? = nil) async throws
52+
-> sending StorageMetadata {
5253
guard let onProgress = onProgress else {
5354
return try await withCheckedThrowingContinuation { continuation in
5455
self.putData(uploadData, metadata: metadata) { result in
@@ -86,7 +87,8 @@ public extension StorageReference {
8687
/// - Returns: `StorageMetadata` with additional information about the object being uploaded.
8788
func putFileAsync(from url: URL,
8889
metadata: StorageMetadata? = nil,
89-
onProgress: ((Progress?) -> Void)? = nil) async throws -> StorageMetadata {
90+
onProgress: ((Progress?) -> Void)? = nil) async throws
91+
-> sending StorageMetadata {
9092
guard let onProgress = onProgress else {
9193
return try await withCheckedThrowingContinuation { continuation in
9294
self.putFile(from: url, metadata: metadata) { result in
@@ -121,7 +123,7 @@ public extension StorageReference {
121123
/// or `fileURL` did not reference a valid path on disk.
122124
/// - Returns: A `URL` pointing to the file path of the downloaded file.
123125
func writeAsync(toFile fileURL: URL,
124-
onProgress: ((Progress?) -> Void)? = nil) async throws -> URL {
126+
onProgress: ((Progress?) -> Void)? = nil) async throws -> sending URL {
125127
guard let onProgress = onProgress else {
126128
return try await withCheckedThrowingContinuation { continuation in
127129
_ = self.write(toFile: fileURL) { result in
@@ -160,7 +162,7 @@ public extension StorageReference {
160162
/// - Throws: An error if the operation failed, for example if Storage was unreachable
161163
/// or the storage reference referenced an invalid path.
162164
/// - Returns: A `StorageListResult` containing the contents of the storage reference.
163-
func list(maxResults: Int64) async throws -> StorageListResult {
165+
func list(maxResults: Int64) async throws -> sending StorageListResult {
164166
typealias ListContinuation = CheckedContinuation<StorageListResult, Error>
165167
return try await withCheckedThrowingContinuation { (continuation: ListContinuation) in
166168
self.list(maxResults: maxResults) { result in
@@ -186,7 +188,7 @@ public extension StorageReference {
186188
/// or the storage reference referenced an invalid path.
187189
/// - Returns:
188190
/// - completion A `Result` enum with either the list or an `Error`.
189-
func list(maxResults: Int64, pageToken: String) async throws -> StorageListResult {
191+
func list(maxResults: Int64, pageToken: String) async throws -> sending StorageListResult {
190192
typealias ListContinuation = CheckedContinuation<StorageListResult, Error>
191193
return try await withCheckedThrowingContinuation { (continuation: ListContinuation) in
192194
self.list(maxResults: maxResults, pageToken: pageToken) { result in

0 commit comments

Comments
 (0)