gpt4 book ai didi

ios - 压缩图像和文本文件并附加到 swift mail composer

转载 作者:行者123 更新时间:2023-11-28 07:44:58 25 4
gpt4 key购买 nike

实际上我有一个图像文件和一个文本文件。我想压缩这两个文件并作为附件添加到 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")
}

并将该 zip 附加到您的邮件编辑器

希望对你有帮助

关于ios - 压缩图像和文本文件并附加到 swift mail composer,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51335496/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com