Created
June 7, 2015 02:14
-
-
Save burritofanatic/cc4e3689eb680eb81a3e to your computer and use it in GitHub Desktop.
Multi-Part Upload to GAE For Images
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
UIImage* importedImage = [info valueForKey:UIImagePickerControllerOriginalImage]; | |
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager]; | |
[manager GET:@"https://snap-picafy.appspot.com/upload_url" parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) { | |
NSLog(@"JSON: %@", responseObject); | |
[manager POST:[responseObject valueForKey:@"uploadURL"] parameters:nil constructingBodyWithBlock:^(id<AFMultipartFormData> formData) { | |
NSData* imageData = UIImagePNGRepresentation(importedImage); | |
[formData appendPartWithFileData:imageData name:@"file" fileName:@"imageSample" mimeType:@"image/png"]; | |
} success:^(AFHTTPRequestOperation *operation, id responseObject) { | |
NSLog(@"Response: %@", responseObject); | |
} failure:^(AFHTTPRequestOperation *operation, NSError *error) { | |
NSLog(@"Error: %@", error); | |
}]; | |
} failure:^(AFHTTPRequestOperation *operation, NSError *error) { | |
NSLog(@"Error: %@", error); | |
}]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment