Linked Questions

Popular Questions

I have an app for iOS that uses metal to render obj files. I am trying to add functionality for users to insert the url of an obj file online and render that. I am using alamofire and am not sure how I will access the file once downloaded, since I won't know the file name.

let destination = DownloadRequest.suggestedDownloadDestination(for: .downloadsDirectory)

let modelUrl = URL(string: "https://drive.google.com/file/d/110KRnku3N_K_EIN-ZLYXK128zjMqxGLM/view?usp=sharing")

Alamofire.download(
    modelUrl!,
    method: .get,
    parameters: Parameters.init(),
    encoding: JSONEncoding.default,
    headers: nil,
    to: destination).downloadProgress(closure: { (progress) in
        //progress closure
    }).response(completionHandler: { (DefaultDownloadResponse) in
        //here you able to access the DefaultDownloadResponse
        //result closure
    })
let file = try? String(contentsOf: URL(string: (NSSearchPathForDirectoriesInDomains(.downloadsDirectory, .userDomainMask, true)[0]))!)

I am also fairly certain my method for retrieving the file will not work, but i'm not sure how to search the documents directory for a specific file. The files I have working are in the project as .obj files in xcode, and I simply use this.

let assetURL = Bundle.main.url(forResource: modelName, withExtension: "obj")

Related Questions