Check Mobile App
Read now
Start a Project

How to make multipart request using Alamofire 3.0 in Swift

Save

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.

Ex:

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.

. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


1 comments

  • anil
    i like it
  • css.php

    Great Product, Great Team, and Great Support Service. And if you want to add more features to the product, they can submit any idea that comes to your mind. They really care about their clients and we are really happy and honored to deal with Webkul.

    Osama
    Talk to Sales

    Global

    Live Chat
    Start a Project

      Message Sent!

      If you have more details or questions, you can reply to the received confirmation email.

      Back to Home