Skip to content

Commit 2d3ecf9

Browse files
authored
Storage docs fixes (#12344)
1 parent 8ec4afc commit 2d3ecf9

10 files changed

+318
-383
lines changed

FirebaseStorage/Sources/AsyncAwait.swift

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ public extension StorageReference {
2424
/// - Parameters:
2525
/// - size: The maximum size in bytes to download. If the download exceeds this size,
2626
/// the task will be cancelled and an error will be thrown.
27-
/// - Throws:
28-
/// - An error if the operation failed, for example if the data exceeded `maxSize`.
27+
/// - Throws: An error if the operation failed, for example if the data exceeded `maxSize`.
2928
/// - Returns: Data object.
3029
func data(maxSize: Int64) async throws -> Data {
3130
return try await withCheckedThrowingContinuation { continuation in
@@ -45,8 +44,7 @@ public extension StorageReference {
4544
/// about the object being uploaded.
4645
/// - onProgress: An optional closure function to return a `Progress` instance while the
4746
/// upload proceeds.
48-
/// - Throws:
49-
/// - An error if the operation failed, for example if Storage was unreachable.
47+
/// - Throws: An error if the operation failed, for example if Storage was unreachable.
5048
/// - Returns: StorageMetadata with additional information about the object being uploaded.
5149
func putDataAsync(_ uploadData: Data,
5250
metadata: StorageMetadata? = nil,
@@ -83,9 +81,8 @@ public extension StorageReference {
8381
/// about the object being uploaded.
8482
/// - onProgress: An optional closure function to return a `Progress` instance while the
8583
/// upload proceeds.
86-
/// - Throws:
87-
/// - An error if the operation failed, for example if no file was present at the specified
88-
/// `url`.
84+
/// - Throws: An error if the operation failed, for example if no file was present at the
85+
/// specified `url`.
8986
/// - Returns: `StorageMetadata` with additional information about the object being uploaded.
9087
func putFileAsync(from url: URL,
9188
metadata: StorageMetadata? = nil,
@@ -119,8 +116,7 @@ public extension StorageReference {
119116
/// - fileUrl: A URL representing the system file path of the object to be uploaded.
120117
/// - onProgress: An optional closure function to return a `Progress` instance while the
121118
/// download proceeds.
122-
/// - Throws:
123-
/// - An error if the operation failed, for example if Storage was unreachable
119+
/// - Throws: An error if the operation failed, for example if Storage was unreachable
124120
/// or `fileURL` did not reference a valid path on disk.
125121
/// - Returns: A `URL` pointing to the file path of the downloaded file.
126122
func writeAsync(toFile fileURL: URL,
@@ -157,13 +153,11 @@ public extension StorageReference {
157153
/// Only available for projects using Firebase Rules Version 2.
158154
///
159155
/// - Parameters:
160-
/// - maxResults The maximum number of results to return in a single page. Must be
156+
/// - maxResults: The maximum number of results to return in a single page. Must be
161157
/// greater than 0 and at most 1000.
162-
/// - Throws:
163-
/// - An error if the operation failed, for example if Storage was unreachable
158+
/// - Throws: An error if the operation failed, for example if Storage was unreachable
164159
/// or the storage reference referenced an invalid path.
165-
/// - Returns:
166-
/// - A `StorageListResult` containing the contents of the storage reference.
160+
/// - Returns: A `StorageListResult` containing the contents of the storage reference.
167161
func list(maxResults: Int64) async throws -> StorageListResult {
168162
typealias ListContinuation = CheckedContinuation<StorageListResult, Error>
169163
return try await withCheckedThrowingContinuation { (continuation: ListContinuation) in
@@ -182,9 +176,9 @@ public extension StorageReference {
182176
/// Only available for projects using Firebase Rules Version 2.
183177
///
184178
/// - Parameters:
185-
/// - maxResults The maximum number of results to return in a single page. Must be
179+
/// - maxResults: The maximum number of results to return in a single page. Must be
186180
/// greater than 0 and at most 1000.
187-
/// - pageToken A page token from a previous call to list.
181+
/// - pageToken: A page token from a previous call to list.
188182
/// - Throws:
189183
/// - An error if the operation failed, for example if Storage was unreachable
190184
/// or the storage reference referenced an invalid path.

FirebaseStorage/Sources/Result.swift

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ private func getResultCallback<T>(completion: @escaping (Result<T, Error>) -> Vo
3838

3939
public extension StorageReference {
4040
/// Asynchronously retrieves a long lived download URL with a revokable token.
41+
///
4142
/// This can be used to share the file with others, but can be revoked by a developer
4243
/// in the Firebase Console.
4344
///
@@ -48,6 +49,7 @@ public extension StorageReference {
4849
}
4950

5051
/// Asynchronously downloads the object at the `StorageReference` to a `Data` object.
52+
///
5153
/// A `Data` of the provided max size will be allocated, so ensure that the device has enough
5254
/// memory to complete. For downloading large files, the `write` API may be a better option.
5355

@@ -73,6 +75,7 @@ public extension StorageReference {
7375
}
7476

7577
/// Resumes a previous `list` call, starting after a pagination token.
78+
///
7679
/// Returns the next set of items (files) and prefixes (folders) under this StorageReference.
7780
///
7881
/// "/" is treated as a path delimiter. Firebase Storage does not support unsupported object
@@ -82,10 +85,10 @@ public extension StorageReference {
8285
/// Only available for projects using Firebase Rules Version 2.
8386
///
8487
/// - Parameters:
85-
/// - maxResults The maximum number of results to return in a single page. Must be
88+
/// - maxResults: The maximum number of results to return in a single page. Must be
8689
/// greater than 0 and at most 1000.
87-
/// - pageToken A page token from a previous call to list.
88-
/// - completion A completion handler that will be invoked with the next items and
90+
/// - pageToken: A page token from a previous call to list.
91+
/// - completion: A completion handler that will be invoked with the next items and
8992
/// prefixes under the current StorageReference. It returns a `Result` enum
9093
/// with either the list or an `Error`.
9194
func list(maxResults: Int64,
@@ -105,9 +108,9 @@ public extension StorageReference {
105108
/// Only available for projects using Firebase Rules Version 2.
106109
///
107110
/// - Parameters:
108-
/// - maxResults The maximum number of results to return in a single page. Must be
111+
/// - maxResults: The maximum number of results to return in a single page. Must be
109112
/// greater than 0 and at most 1000.
110-
/// - completion A completion handler that will be invoked with the next items and
113+
/// - completion: A completion handler that will be invoked with the next items and
111114
/// prefixes under the current `StorageReference`. It returns a `Result` enum
112115
/// with either the list or an `Error`.
113116
func list(maxResults: Int64,
@@ -125,7 +128,7 @@ public extension StorageReference {
125128
/// Only available for projects using Firebase Rules Version 2.
126129
///
127130
/// - Parameters:
128-
/// - completion A completion handler that will be invoked with all items and prefixes
131+
/// - completion: A completion handler that will be invoked with all items and prefixes
129132
/// under the current StorageReference. It returns a `Result` enum with either the
130133
/// list or an `Error`.
131134
func listAll(completion: @escaping (Result<StorageListResult, Error>) -> Void) {
@@ -136,10 +139,10 @@ public extension StorageReference {
136139
/// This is not recommended for large files, and one should instead upload a file from disk.
137140
///
138141
/// - Parameters:
139-
/// - uploadData The `Data` to upload.
140-
/// - metadata `StorageMetadata` containing additional information (MIME type, etc.)
142+
/// - uploadData: The `Data` to upload.
143+
/// - metadata: `StorageMetadata` containing additional information (MIME type, etc.)
141144
/// about the object being uploaded.
142-
/// - completion A completion block that returns a `Result` enum with either the
145+
/// - completion: A completion block that returns a `Result` enum with either the
143146
/// object metadata or an `Error`.
144147
///
145148
/// - Returns: An instance of `StorageUploadTask`, which can be used to monitor or manage
@@ -157,10 +160,10 @@ public extension StorageReference {
157160
/// Asynchronously uploads a file to the currently specified `StorageReference`.
158161
///
159162
/// - Parameters:
160-
/// - from A URL representing the system file path of the object to be uploaded.
161-
/// - metadata `StorageMetadata` containing additional information (MIME type, etc.)
163+
/// - from: A URL representing the system file path of the object to be uploaded.
164+
/// - metadata: `StorageMetadata` containing additional information (MIME type, etc.)
162165
/// about the object being uploaded.
163-
/// - completion A completion block that returns a `Result` enum with either the
166+
/// - completion: A completion block that returns a `Result` enum with either the
164167
/// object metadata or an `Error`.
165168
///
166169
/// - Returns: An instance of `StorageUploadTask`, which can be used to monitor or manage
@@ -178,8 +181,8 @@ public extension StorageReference {
178181
/// Updates the metadata associated with an object at the current path.
179182
///
180183
/// - Parameters:
181-
/// - metadata A `StorageMetadata` object with the metadata to update.
182-
/// - completion A completion block which returns a `Result` enum with either the
184+
/// - metadata: A `StorageMetadata` object with the metadata to update.
185+
/// - completion: A completion block which returns a `Result` enum with either the
183186
/// object metadata or an `Error`.
184187
func updateMetadata(_ metadata: StorageMetadata,
185188
completion: @escaping (Result<StorageMetadata, Error>) -> Void) {
@@ -189,8 +192,8 @@ public extension StorageReference {
189192
/// Asynchronously downloads the object at the current path to a specified system filepath.
190193
///
191194
/// - Parameters:
192-
/// - toFile A file system URL representing the path the object should be downloaded to.
193-
/// - completion A completion block that fires when the file download completes. The
195+
/// - toFile: A file system URL representing the path the object should be downloaded to.
196+
/// - completion: A completion block that fires when the file download completes. The
194197
/// block returns a `Result` enum with either an NSURL pointing to the file
195198
/// path of the downloaded file or an `Error`.
196199
///

0 commit comments

Comments
 (0)