mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
21 lines
544 B
Swift
21 lines
544 B
Swift
import Foundation
|
|
#if os(macOS)
|
|
import PostboxMac
|
|
#else
|
|
import Postbox
|
|
#endif
|
|
|
|
public func decryptedResourceData(data: MediaResourceData, resource: MediaResource, params: Any) -> Data? {
|
|
guard data.complete else {
|
|
return nil
|
|
}
|
|
guard let data = try? Data(contentsOf: URL(fileURLWithPath: data.path), options: [.mappedRead]) else {
|
|
return nil
|
|
}
|
|
if let resource = resource as? EncryptedMediaResource {
|
|
return resource.decrypt(data: data, params: params)
|
|
} else {
|
|
return data
|
|
}
|
|
}
|