Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Swift 3 pdf文件下载不起作用_Swift_Download_Swift3 - Fatal编程技术网

Swift 3 pdf文件下载不起作用

Swift 3 pdf文件下载不起作用,swift,download,swift3,Swift,Download,Swift3,我有这样一个url: http://*****.ru/cgi-bin/****/****/cgi.exe?LNG=&C21COM=2&I21DBN=EKU_XML&P21DBN=EKU&Z21ID=1482179537193C7C43181117E030&Image_file_name=%5CFULL%5FTEXT%5CELBIB%5CNarodnye%5Fprazdniki%2Epdf&IMAGE_FILE_DOWNLOAD=1&SECU

我有这样一个url:

http://*****.ru/cgi-bin/****/****/cgi.exe?LNG=&C21COM=2&I21DBN=EKU_XML&P21DBN=EKU&Z21ID=1482179537193C7C43181117E030&Image_file_name=%5CFULL%5FTEXT%5CELBIB%5CNarodnye%5Fprazdniki%2Epdf&IMAGE_FILE_DOWNLOAD=1&SECUR=LOG&RIGHT=ALL
此url用于下载*.PDF文件

我使用此功能下载文件

//method to be called to download
func download(url: URL)
{
    self.url = url
    //download identifier can be customized. I used the "ulr.absoluteString"
    let sessionConfig = URLSessionConfiguration.background(withIdentifier: url.absoluteString)
    let session = Foundation.URLSession(configuration: sessionConfig,     delegate: self, delegateQueue: nil)
    let task = session.downloadTask(with: url)
    task.resume()
}

调用此函数后,我得到的是cgi.exe文件,而不是pdf文件。为什么会发生这种情况?

根据您的URL,我可以假设您正在使用参数启动cgi.exe以生成pdf文件。我认为,您需要向您的cgi.exe发送一个生成文件的请求,并在响应中放置到生成的.pdf文件的适当链接。然后使用此URL开始下载操作

希望能有帮助