send image array alamofire swif t

Alamofire.upload(multipartFormData: { multipartFormData in
            // import image to request
            for imageData in imagesData {
                multipartFormData.append(imageData, withName: "\(imageParamName)[]", fileName: "\(Date().timeIntervalSince1970).jpeg", mimeType: "image/jpeg")
            }
            for (key, value) in parameters {
                multipartFormData.append(value.data(using: String.Encoding.utf8)!, withName: key)
            }
        }, to: urlString,

            encodingCompletion: { encodingResult in
                switch encodingResult {
                case .success(let upload, _, _):
                    upload.responseJSON { response in

                    }
                case .failure(let error):
                    print(error)
                }

        })

4.13
11
Dudusan 90 points

                                        headerFile()
   
    AF.upload(multipartFormData: { multipartFormData in
        
        for (key, value) in parameters {
            if let temp = value as? String {
                multipartFormData.append(temp.data(using: .utf8)!, withName: key)
            }
            if let temp = value as? Int {
                multipartFormData.append("\(temp)".data(using: .utf8)!, withName: key)
            }
            if let temp = value as? NSArray {
                temp.forEach({ element in
                    let keyObj = key + "[]"
                    if let string = element as? String {
                        multipartFormData.append(string.data(using: .utf8)!, withName: keyObj)
                    } else
                        if let num = element as? Int {
                            let value = "\(num)"
                            multipartFormData.append(value.data(using: .utf8)!, withName: keyObj)
                    }
                })
            }
        }
        
        if let data = imageData{
            multipartFormData.append(data, withName: "file", fileName: "\(Date.init().timeIntervalSince1970).png", mimeType: "image/png")
        }
    },
              to: endUrl, method: .post , headers: headers)
        .responseJSON(completionHandler: { (response) in
            
            print(response)
            
            if let err = response.error{
                print(err)
                onError?(err)
                return
            }
            print("Succesfully uploaded")
            
            let json = response.data
            
            if (json != nil)
            {
                let jsonObject = JSON(json!)
                print(jsonObject)
            }
        })
  }

4.13 (8 Votes)
0
Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
alamofire upload image from gallery with parameters swift 5 image upload in swift 5 using alamofire upload image with alamofire swift 5 alamofire upload image with body swift 4 uploading image file using alamofire swift 5 upload image alamofire swift how to upload image using alamofire in swift 4 alamofire upload image fast in swift' fast upload using alamofire swift 5 upload image in server swift alamofire upload multiple image with parameters swift 5 alamofire upload image swift 5 case .success(let upload, _, _) alamo fire error upload a single image alamofire 5.0 swift swift alamofire upload image to wordpress server swift alamofire upload image to server alamofire 4 upload how to post image and key value pairs in almonfire parameters in swift 5 how to post image in almonfire parameters in swift 5 alamofire upload file without multipart alamofire 5 UIImage upload swift alamofire 5 image upload swift alamofire image file upload alamofire upload image request alamofire upload image with parameters swift 4 pick image from gallery ios swift to server alamofire alamofire send image Upload almofire image with multipart form-data iOS in Swift alamofire upload multipartformdata video post images with params alamofire swift 5 alamofire 5 upload image to url alamofire upload image alamofire upload image multipart or url upload image in multipart usinf alamofire upload image multipart using alamofire multipart request image uploading alamofire send image array alamofire swif t upload image with parameters in swift 4 using alamofire alamofire camera upload image issue swift alamofire upload image isue alamofire upload image with parameters swift 5 upload image alamofre swift how upload image using multipart swift
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source