实际上我有一个图像文件和文本文件。我想压缩两个文件,并作为附件添加到快速邮件编辑器中。有什么办法吗?请帮助
答案 0 :(得分:0)
您可以使用
压缩文件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")
}
并将该zip附加到您的邮件编辑器
希望对您有帮助