소스 검색

Adds putFileHandle and putFileHandleAsync (#12580)

Co-authored-by: Nick Cooke <36927374+ncooke3@users.noreply.github.com>
Matt Comi 2 년 전
부모
커밋
8230f73de8

+ 1 - 0
FirebaseStorage.podspec

@@ -42,6 +42,7 @@ Firebase Storage provides robust, secure file uploads and downloads from Firebas
   s.dependency 'FirebaseCore', '~> 10.0'
   s.dependency 'FirebaseCoreExtension', '~> 10.0'
   s.dependency 'GTMSessionFetcher/Core', '>= 2.1', '< 4.0'
+  s.dependency 'GoogleUtilities/Environment', '~> 7.12'
 
   s.test_spec 'ObjCIntegration' do |objc_tests|
     objc_tests.scheme = { :code_coverage => true }

+ 4 - 0
FirebaseStorage/CHANGELOG.md

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

+ 0 - 1
FirebaseStorage/Sources/AsyncAwait.swift

@@ -73,7 +73,6 @@ public extension StorageReference {
   }
 
   /// Asynchronously uploads a file to the currently specified StorageReference.
-  /// `putDataAsync` should be used instead of `putFileAsync` in Extensions.
   ///
   /// - Parameters:
   ///   - url: A URL representing the system file path of the object to be uploaded.

+ 0 - 3
FirebaseStorage/Sources/StorageReference.swift

@@ -136,7 +136,6 @@ import Foundation
   }
 
   /// Asynchronously uploads a file to the currently specified `StorageReference`.
-  /// `putData` should be used instead of `putFile` in Extensions.
   /// - Parameters:
   ///   - fileURL: A URL representing the system file path of the object to be uploaded.
   ///   - metadata: `StorageMetadata` containing additional information (MIME type, etc.)
@@ -150,7 +149,6 @@ import Foundation
 
   /// Asynchronously uploads a file to the currently specified `StorageReference`,
   /// without additional metadata.
-  /// `putData` should be used instead of `putFile` in Extensions.
   /// @param fileURL A URL representing the system file path of the object to be uploaded.
   /// @return An instance of StorageUploadTask, which can be used to monitor or manage the upload.
   @objc(putFile:) @discardableResult open func __putFile(from fileURL: URL) -> StorageUploadTask {
@@ -158,7 +156,6 @@ import Foundation
   }
 
   /// Asynchronously uploads a file to the currently specified `StorageReference`.
-  /// `putData` should be used instead of `putFile` in Extensions.
   /// - Parameters:
   ///   - fileURL: A URL representing the system file path of the object to be uploaded.
   ///   - metadata: `StorageMetadata` containing additional information (MIME type, etc.)

+ 10 - 0
FirebaseStorage/Sources/StorageUploadTask.swift

@@ -14,6 +14,12 @@
 
 import Foundation
 
+#if SWIFT_PACKAGE
+  @_implementationOnly import GoogleUtilities_Environment
+#else
+  @_implementationOnly import GoogleUtilities
+#endif // SWIFT_PACKAGE
+
 #if COCOAPODS
   import GTMSessionFetcher
 #else
@@ -87,6 +93,10 @@ import Foundation
       } else if let fileURL = self.fileURL {
         uploadFetcher.uploadFileURL = fileURL
         uploadFetcher.comment = "File UploadTask"
+
+        if GULAppEnvironmentUtil.isAppExtension() {
+          uploadFetcher.useBackgroundSession = false
+        }
       }
       uploadFetcher.maxRetryInterval = self.reference.storage.maxUploadRetryInterval
 

+ 1 - 0
Package.swift

@@ -1161,6 +1161,7 @@ let package = Package(
         "FirebaseCore",
         "FirebaseCoreExtension",
         .product(name: "GTMSessionFetcherCore", package: "gtm-session-fetcher"),
+        .product(name: "GULEnvironment", package: "GoogleUtilities"),
       ],
       path: "FirebaseStorage/Sources"
     ),