Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

196
Views
Alamofire upload with mutli part form data

Updating code base to Swift 3. Was testing uploading images and videos and found an unusual use bug. Alamofire is updated and current on pod version "4.3.0".

Some images upload to s3 just fine, while others are only uploading around 104kb out of what is usually around 3 to 4mb worth of data. Video uploads work without any issues. All uploads use the same code path.

There are no errors thrown. The uploads in question show up as a black box.

Has anyone seen anything similar since updating? Is there a syntax change that I missed after looking at the updated Alamofire readme? Any ideas or feedback on possible causes is greatly appreciated!

The upload logic in question:

let uploadToken = UploadToken(dictionary: result)
  Alamofire.upload(multipartFormData: { (multipartFormData) in
    for (key, data) in uploadToken.s3Policy {
      if let encodedData = (data as! String).data(using: .utf8) {
        multipartFormData.append(encodedData, withName: key)
      }
    }

    multipartFormData.append(url, withName: "file")
  }, to: uploadToken.urlString, encodingCompletion: { (result) in
    switch (result) {
    case .failure(let error):
      completionHandler(nil, .uploadFailed(error as NSError))
    case .success(let request, _, _):
      request.uploadProgress(closure: { (progress) in
        let percentComplete = (progress.fractionCompleted * 0.9) + 0.1
        progressHandler(Float(percentComplete))
      })

      request.validate().response(completionHandler: { (_) in
        completionHandler(uploadToken.id, nil)
      })
    }
  })
over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!