Redeem Now
Read More
Read now

How to make multipart request using Alamofire 3.0 in Swift


Multipart Request

Sometimes we need to upload the multiple images to a server in a single request, for this Alamofire 3.0 provide the upload facility where we can upload ‘n’ number of images in the single request.

For this we have to follow some steps;

1: First we have to fetch all images in a single array and store all UIImage object in the array.


var imageDataArray:NSMutableArray = []

2: Now collect all the data which you have to send like params, headers or any data

Note: don’t access the data which is on the main thread, when you are uploading the images to server because upload works on background thread only.

Ex: like fetching the value from UItextfield etc;

3: define header in ViewdidLoad()

4: Now its time to define the method :


Note:  a: imageFlagArray  -> is bool array to check the array contains UIImage data or not.

b:  self.imageDataArray[i]  -> it contains UIImage object of Images.

c: self.UPLOAD_URL – > it is base URL where we have to upload.

d: self.headers -> it is header which I have defined in viewdidload method;

Now check the proper params and header field, upload URL then try it.

















. . .

Comment (1)

Add Your Comment

  • anil
    i like it
  • css.php
    Hire Us!
    Brief us about your requirements and we'll get back to you.
    Woo! Hooy!
    We have just recieved your project brief and our expert will contact you shortly.
    Send Again