How do I Pass a parameter while uploading a file to an API with Alamofire 5

105 views Asked by At

I am trying to upload a PDF selected from document picker view(Files App) to an api but I would like to pass parameters with it but I'm not able to.

Code used to upload the file:



 AF.upload(myURL, to: "API Upload Link")
        .authenticate(username: username, password: password)
      .uploadProgress { progress in
          print("Upload Progress: \(progress.fractionCompleted)")
        
      }
  
      .downloadProgress { progress in
          print("Download Progress: \(progress.fractionCompleted)")
      }
        AF.request("API Upload Link").responseJSON { response in
         print("Response: \(response)")
        }

myUrl is the path of the document selected and I am able to upload the document.

But how do I pass parameters with this document while uploading the doc. eg "DocumentType" : "Passport"

The File type is always a PDF.

Thanks in Advance!

0

There are 0 answers