Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion FirebaseStorageSwift/Sources/AsyncAwait.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import Foundation

#if compiler(>=5.5) && canImport(_Concurrency)
@available(iOS 15, tvOS 15, macOS 12, watchOS 8, *)
@available(iOS 13, tvOS 13, macOS 10.15, watchOS 8, *)
public extension StorageReference {
/// Asynchronously downloads the object at the StorageReference to a Data object in memory.
/// A Data object of the provided max size will be allocated, so ensure that the device has
Expand Down
64 changes: 64 additions & 0 deletions FirebaseStorageSwift/Sources/StorageReference.swift
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,19 @@ import FirebaseStorageObjC
impl.downloadURL(completion: completion)
}

#if compiler(>=5.5) && canImport(_Concurrency)
@available(iOS 13, tvOS 13, macOS 10.15, watchOS 8, *)
/**
* Asynchronously retrieves a long lived download URL with a revokable token.
* This can be used to share the file with others, but can be revoked by a developer
* in the Firebase Console.
* @returns completion The URL on success.
*/
open func downloadURL() async throws -> URL {
return try await impl.downloadURL()
}
#endif // compiler(>=5.5) && canImport(_Concurrency)

/**
* Asynchronously downloads the object at the current path to a specified system filepath.
* @param fileURL A file system URL representing the path the object should be downloaded to.
Expand Down Expand Up @@ -257,6 +270,24 @@ import FirebaseStorageObjC
}
}

#if compiler(>=5.5) && canImport(_Concurrency)
@available(iOS 13, tvOS 13, macOS 10.15, watchOS 8, *)
/**
* List all items (files) and prefixes (folders) under this StorageReference.
*
* This is a helper method for calling list() repeatedly until there are no more results.
* Consistency of the result is not guaranteed if objects are inserted or removed while this
* operation is executing. All results are buffered in memory.
*
* `listAll()` is only available for projects using Firebase Rules Version 2.
*
* @returns completion All items and prefixes under the current StorageReference.
*/
open func listAll() async throws -> StorageListResult {
return try await StorageListResult(impl.listAll())
}
#endif // compiler(>=5.5) && canImport(_Concurrency)

/**
* List up to `maxResults` items (files) and prefixes (folders) under this StorageReference.
*
Expand Down Expand Up @@ -327,6 +358,17 @@ import FirebaseStorageObjC
}
}

#if compiler(>=5.5) && canImport(_Concurrency)
@available(iOS 13, tvOS 13, macOS 10.15, watchOS 8, *)
/**
* Retrieves metadata associated with an object at the current path.
* @returns The object metadata on success.
*/
open func getMetadata() async throws -> StorageMetadata {
return try await StorageMetadata(impl: impl.metadata())
}
#endif // compiler(>=5.5) && canImport(_Concurrency)

/**
* Updates the metadata associated with an object at the current path.
* @param metadata An StorageMetadata object with the metadata to update.
Expand All @@ -343,6 +385,18 @@ import FirebaseStorageObjC
}
}

#if compiler(>=5.5) && canImport(_Concurrency)
@available(iOS 13, tvOS 13, macOS 10.15, watchOS 8, *)
/**
* Updates the metadata associated with an object at the current path.
* @param metadata An StorageMetadata object with the metadata to update.
* @returns The object metadata on success.
*/
open func updateMetadata(_ metadata: StorageMetadata) async throws -> StorageMetadata {
return try await StorageMetadata(impl: impl.update(metadata.impl))
}
#endif // compiler(>=5.5) && canImport(_Concurrency)

private func adaptMetadataCallback(completion: @escaping (StorageMetadata?, Error?) -> Void) ->
(_: FIRIMPLStorageMetadata?, _: Error?)
-> Void {
Expand All @@ -366,6 +420,16 @@ import FirebaseStorageObjC
impl.delete(completion: completion)
}

#if compiler(>=5.5) && canImport(_Concurrency)
@available(iOS 13, tvOS 13, macOS 10.15, watchOS 8, *)
/**
* Deletes the object at the current path.
*/
open func delete() async throws {
return try await impl.delete()
}
#endif // compiler(>=5.5) && canImport(_Concurrency)

// MARK: - NSObject overrides

@objc open func copy(_ zone: NSZone) -> StorageReference {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import FirebaseCore
import FirebaseStorage
import XCTest

#if swift(>=5.9)
@available(iOS 15, *)
#if swift(>=5.5) && canImport(_Concurrency)
@available(iOS 13.0, macOS 10.15, macCatalyst 13.0, tvOS 13.0, watchOS 6.0, *)
class StorageAsyncAwait: StorageIntegrationCommon {
func testGetMetadata() async throws {
let ref = storage.reference().child("ios/public/1mb2")
Expand Down