diff --git a/FlowCrypt/Core/CoreTypes.swift b/FlowCrypt/Core/CoreTypes.swift index 7675ba26e..b2407a9b7 100644 --- a/FlowCrypt/Core/CoreTypes.swift +++ b/FlowCrypt/Core/CoreTypes.swift @@ -215,9 +215,10 @@ struct MsgBlock: Decodable { struct AttMeta: Decodable { let name: String - let data: String + let data: String? let type: String let length: Int + let url: String? let treatAs: String? } diff --git a/FlowCrypt/Functionality/Mail Provider/Message Provider/MessageAttachment.swift b/FlowCrypt/Functionality/Mail Provider/Message Provider/MessageAttachment.swift index 819f7f048..b9525708d 100644 --- a/FlowCrypt/Functionality/Mail Provider/Message Provider/MessageAttachment.swift +++ b/FlowCrypt/Functionality/Mail Provider/Message Provider/MessageAttachment.swift @@ -54,10 +54,17 @@ extension MessageAttachment { } init?(attMeta: MsgBlock.AttMeta) { - guard let data = Data(base64Encoded: attMeta.data.data()) else { + if let urlString = attMeta.url, let url = URL(string: urlString) { + // Fetch data synchronously from the URL + if let urlData = try? Data(contentsOf: url) { + self.init(name: attMeta.name, data: urlData, mimeType: attMeta.type, treatAs: "encryptedFile") + return + } + return nil + } + guard let attData = attMeta.data, let data = Data(base64Encoded: attData.data()) else { return nil } - self.init(name: attMeta.name, data: data, mimeType: attMeta.type, treatAs: attMeta.treatAs) } }