实际上我有一个图像文件和文本文件。我想压缩这两个文件并作为附件添加到swift mail composer。有什么解决办法吗?请帮忙
最佳答案
你可以用这个压缩你的文件
https://github.com/marmelroy/Zip库
下面是添加的示例代码
do {
let filePath = Bundle.main.url(forResource: "file", withExtension: "zip")!
let documentsDirectory = FileManager.default.urls(for:.documentDirectory, in: .userDomainMask)[0]
try Zip.unzipFile(filePath, destination: documentsDirectory, overwrite: true, password: "password", progress: { (progress) -> () in
print(progress)
}) // Unzip
let zipFilePath = documentsFolder.appendingPathComponent("archive.zip")
try Zip.zipFiles([filePath], zipFilePath: zipFilePath, password: "password", progress: { (progress) -> () in
print(progress)
}) //Zip
}
catch {
print("Something went wrong")
}
把那个拉链系在你的邮件生成器上
希望能有所帮助
关于ios - 压缩图像和文本文件并附加到Swift Mail Composer,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/51335496/