Alamofire.download() method: Where is the file and did it save successfully?

后端 未结 5 711
无人及你
无人及你 2021-02-02 11:16

The example for using Alamofire.download() works just fine, but there isn\'t any detail in how to access the resulting downloaded file. I can figure out where the file is and wh

5条回答
  •  梦谈多话
    2021-02-02 11:43

    This answer from an Alamofire member seems to be the best answer:

    let destination = Alamofire.Request.suggestedDownloadDestination(
        directory: .CachesDirectory,
        domain: .UserDomainMask
    )
    
    Alamofire.download(.GET, "http://www.adobe.com/devnet/acrobat/pdfs/pdf_open_parameters.pdf", destination: destination)
        .progress { bytesRead, totalBytesRead, totalBytesExpectedToRead in
            print(totalBytesRead)
        }
        .response { request, response, _, error in
            print(response)
            print("fileURL: \(destination(NSURL(string: "")!, response))")
    }
    

提交回复
热议问题