mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-07-26 13:10:43 +00:00

git-subtree-dir: submodules/TelegramCore git-subtree-mainline: 971273e8f8f49a47f14b251d2f35e3445a61fc3f git-subtree-split: 9561227540acef69894e6546395ab223a6233600
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
|
|
}
|
|
}
|