I am working with an app that will download remote files from the web to the local Documents folder of the app.
The user needs to know the Content-Length
(i.e: file size) before deciding to download or not, to avoid wasting resources.
I have seen the answer in this question How to download file in swift?
but that answer downloads the whole file.
and using:
String(contentsOf: URL(string: "https://example.com/file.txt")!)
will download the file, not the headers. I am looking for an alternative to
curl --headers "http://example.com/file.txt"
but for swift... Is there a way to let iOS operating system do that for me? like shell
or shell_execute()
or something like that?
How can I do that?