IOS uses afnetworking to upload single, multiple photos to the background

Source: Internet
Author: User

We said that the first way to upload pictures is to transfer the pictures to the image stream to upload; Today we are going to introduce another approach. is to use the method of afnetworking in the use of URLs to upload the way. Concrete backstage how to receive I don't know clearly.
The old words do not say more directly on the code.


Afhttprequestoperationmanager *manager = [Afhttprequestoperationmanager manager];//instantiation AFN
Afjsonresponseserializer *response = [Afjsonresponseserializer serializer];
JSON transfer Mode
Response.removeskeyswithnullvalues = YES;
Manager.responseserializer = response;

Manager.requestserializer = [Afhttprequestserializer serializer];


[Manager Post:url Parameters:
Nsdictionary
Constructingbodywithblock:
(void (^) (id<afmultipartformdata>))
success:^ (afhttprequestoperation * _nonnull operation, id _nonnull responseobject) {

Success (Responseobject);
} failure:^ (Afhttprequestoperation * _nonnull operation, Nserror * _nonnull error) {
Failure (error);
}];

where (void (^) (id<afmultipartformdata>)) is uploaded to the image

The picture can be a single sheet or multiple sheets.
Leaflet: [FormData appendpartwithfiledata:uiimagepngrepresentation (image) name:@ "Images" filename:@ "Name.png" mimetype:@ "Image/png"];
Multiple: This method to do a loop to arrange the picture into a queue;
Note: The Namec parameter must be the same as the background, otherwise the background will not receive

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.