Skip to content

Commit 8230f73

Browse files
mattcomincooke3
andauthored
Adds putFileHandle and putFileHandleAsync (#12580)
Co-authored-by: Nick Cooke <36927374+ncooke3@users.noreply.github.com>
1 parent e7e03c7 commit 8230f73

File tree

6 files changed

+16
-4
lines changed

6 files changed

+16
-4
lines changed

FirebaseStorage.podspec

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ Firebase Storage provides robust, secure file uploads and downloads from Firebas
4242
s.dependency 'FirebaseCore', '~> 10.0'
4343
s.dependency 'FirebaseCoreExtension', '~> 10.0'
4444
s.dependency 'GTMSessionFetcher/Core', '>= 2.1', '< 4.0'
45+
s.dependency 'GoogleUtilities/Environment', '~> 7.12'
4546

4647
s.test_spec 'ObjCIntegration' do |objc_tests|
4748
objc_tests.scheme = { :code_coverage => true }

FirebaseStorage/CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# Unreleased
2+
- [fixed] `putFile` and `putFileAsync` now work in app extensions. A background session
3+
configuration is not used when uploading from an app extension (#12579).
4+
15
# 10.11.0
26
- [added] Add progress tracking capability for `putDataAsync`, `putFileAsync`, and
37
`writeAsync`. (#10574)

FirebaseStorage/Sources/AsyncAwait.swift

-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ public extension StorageReference {
7373
}
7474

7575
/// Asynchronously uploads a file to the currently specified StorageReference.
76-
/// `putDataAsync` should be used instead of `putFileAsync` in Extensions.
7776
///
7877
/// - Parameters:
7978
/// - url: A URL representing the system file path of the object to be uploaded.

FirebaseStorage/Sources/StorageReference.swift

-3
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,6 @@ import Foundation
136136
}
137137

138138
/// Asynchronously uploads a file to the currently specified `StorageReference`.
139-
/// `putData` should be used instead of `putFile` in Extensions.
140139
/// - Parameters:
141140
/// - fileURL: A URL representing the system file path of the object to be uploaded.
142141
/// - metadata: `StorageMetadata` containing additional information (MIME type, etc.)
@@ -150,15 +149,13 @@ import Foundation
150149

151150
/// Asynchronously uploads a file to the currently specified `StorageReference`,
152151
/// without additional metadata.
153-
/// `putData` should be used instead of `putFile` in Extensions.
154152
/// @param fileURL A URL representing the system file path of the object to be uploaded.
155153
/// @return An instance of StorageUploadTask, which can be used to monitor or manage the upload.
156154
@objc(putFile:) @discardableResult open func __putFile(from fileURL: URL) -> StorageUploadTask {
157155
return putFile(from: fileURL, metadata: nil, completion: nil)
158156
}
159157

160158
/// Asynchronously uploads a file to the currently specified `StorageReference`.
161-
/// `putData` should be used instead of `putFile` in Extensions.
162159
/// - Parameters:
163160
/// - fileURL: A URL representing the system file path of the object to be uploaded.
164161
/// - metadata: `StorageMetadata` containing additional information (MIME type, etc.)

FirebaseStorage/Sources/StorageUploadTask.swift

+10
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@
1414

1515
import Foundation
1616

17+
#if SWIFT_PACKAGE
18+
@_implementationOnly import GoogleUtilities_Environment
19+
#else
20+
@_implementationOnly import GoogleUtilities
21+
#endif // SWIFT_PACKAGE
22+
1723
#if COCOAPODS
1824
import GTMSessionFetcher
1925
#else
@@ -87,6 +93,10 @@ import Foundation
8793
} else if let fileURL = self.fileURL {
8894
uploadFetcher.uploadFileURL = fileURL
8995
uploadFetcher.comment = "File UploadTask"
96+
97+
if GULAppEnvironmentUtil.isAppExtension() {
98+
uploadFetcher.useBackgroundSession = false
99+
}
90100
}
91101
uploadFetcher.maxRetryInterval = self.reference.storage.maxUploadRetryInterval
92102

Package.swift

+1
Original file line numberDiff line numberDiff line change
@@ -1161,6 +1161,7 @@ let package = Package(
11611161
"FirebaseCore",
11621162
"FirebaseCoreExtension",
11631163
.product(name: "GTMSessionFetcherCore", package: "gtm-session-fetcher"),
1164+
.product(name: "GULEnvironment", package: "GoogleUtilities"),
11641165
],
11651166
path: "FirebaseStorage/Sources"
11661167
),

0 commit comments

Comments
 (0)