如何在 Swift 中从服务器下载 zip 文件? [英] How to download zip file from server in Swift?

查看:63
本文介绍了如何在 Swift 中从服务器下载 zip 文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从服务器下载 zip 文件并解压缩该文件以在 Swift 中获取其内容.NSURLSession 的正常方式是否有效?对我有什么建议吗?谢谢!

I am trying to download zip file from server and unzip the file to get its content in Swift. Does the normal way of NSURLSession work? Any advices for me? Thanks!

推荐答案

我觉得这个问题有点宽泛,所以把它当作一个简短而笼统的答案.

I think that the question is a little broad, so consider this as a short and generic answer.

第一:

  • 您需要下载存档文件 - 您可能想要使用此方法-.
  • 下载文件后,您应该将其保存在一个目录中 - 比如documents-.

查看这个答案,了解如何实现这些步骤.

Check this answer to know how you can achive those steps.

第二:

获取存档文件后,您将其解压缩 - 我建议使用第三方库来执行此操作,例如 SSZipArchive-.

After getting the archived file, you will unarchive it -I suggest to use a third-party library for doing this, such as SSZipArchive-.

另外:

您可以使用 Alamofire 来处理下载过程.

You could use Alamofire to handle the downloading proccess.

希望这有帮助.

这篇关于如何在 Swift 中从服务器下载 zip 文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆