Skip to content

Commit

Permalink
Adds putFileHandle and putFileHandleAsync (#12580)
Browse files Browse the repository at this point in the history
Co-authored-by: Nick Cooke <[email protected]>
  • Loading branch information
mattcomi and ncooke3 authored Mar 27, 2024
1 parent e7e03c7 commit 8230f73
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 4 deletions.
1 change: 1 addition & 0 deletions FirebaseStorage.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
4 changes: 4 additions & 0 deletions FirebaseStorage/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
1 change: 0 additions & 1 deletion FirebaseStorage/Sources/AsyncAwait.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 0 additions & 3 deletions FirebaseStorage/Sources/StorageReference.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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.)
Expand All @@ -150,15 +149,13 @@ 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 {
return putFile(from: fileURL, metadata: nil, completion: nil)
}

/// 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.)
Expand Down
10 changes: 10 additions & 0 deletions FirebaseStorage/Sources/StorageUploadTask.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1161,6 +1161,7 @@ let package = Package(
"FirebaseCore",
"FirebaseCoreExtension",
.product(name: "GTMSessionFetcherCore", package: "gtm-session-fetcher"),
.product(name: "GULEnvironment", package: "GoogleUtilities"),
],
path: "FirebaseStorage/Sources"
),
Expand Down

0 comments on commit 8230f73

Please sign in to comment.