Inherits from OlapicHandler : NSObject
Declared in OlapicUploaderHandler.h

Overview

The object in charge of the uploader’s common functionalities

Instance Methods

getUploaderFromMedia:onSuccess:onFailure:

Get an uploader from a media object

- (void)getUploaderFromMedia:(OlapicMediaEntity *)media onSuccess:(void ( ^ ) ( OlapicUploaderEntity *uploader ))success onFailure:(void ( ^ ) ( NSError *error ))failure

Parameters

media

The media object

success

A callback block for when the uploader is successfully retrieved

failure

A callback block for when the SDK can’t get the uploader

Availability

v1.0

Discussion

Example:

[[[OlapicSDK sharedOlapicSDK] uploaders] getUploaderFromMedia:mediaEntityObject
                                         onSuccess:^(OlapicUploaderEntity *uploader){
                                             label.text = [uploader get:@"name"];
                                         }
                                         onFailure:^(NSError *error){
                                             NSLog(@"Error: %@",error.description);
                                         }];

Declared In

OlapicUploaderHandler.h

getUploaderFromURL:onSuccess:onFailure:

Get an uploader from its API URL

- (void)getUploaderFromURL:(NSString *)URL onSuccess:(void ( ^ ) ( OlapicUploaderEntity *uploader ))success onFailure:(void ( ^ ) ( NSError *error ))failure

Parameters

URL

The uploader API URL

success

A callback block for when the uploader is successfully retrieved

failure

A callback block for when the SDK can’t get the uploader

Availability

v1.0

Discussion

Example:

[[[OlapicSDK sharedOlapicSDK] uploaders] getUploaderFromURL:@"users/001"
                                         onSuccess:^(OlapicUploaderEntity *uploader){
                                             label.text = [uploader get:@"name"];
                                         }
                                         onFailure:^(NSError *error){
                                             NSLog(@"Error: %@",error.description);
                                         }];

Declared In

OlapicUploaderHandler.h

uploadMediaFromUploader:imageData:metadata:onSuccess:onFailure:

Upload a media object

- (void)uploadMediaFromUploader:(OlapicUploaderEntity *)uploader imageData:(NSData *)imageData metadata:(NSDictionary *)metadata onSuccess:(void ( ^ ) ( OlapicMediaEntity *media ))success onFailure:(void ( ^ ) ( NSError *error ))failure

Parameters

uploader

The uploader entity that will ‘own’ the media

imageData

The image to upload, on data format

metadata

The media information

  • NSString caption -required
  • NSString latitude -optional
  • NSString longitude -optional
  • NSArray stream -stream
success

A callback block for when the media is successfully uploaded

failure

A callback block for when the media can’t be uploaded

Availability

v1.0

Discussion

Example:

NSMutableDictionary *metadata = [[NSMutableDictionary alloc] init];
// Required
[metadata setValue:@"A brief description for the photo" forKey:@"caption"];
// Optional
// - Location
[metadata setValue:@"latitude" forKey:@"latitude"];
[metadata setValue:@"longitude" forKey:@"longitude"];
// - Streams
NSArray *streams = [[NSArray alloc] initWithObjects:streamEntityObject1,streamEntityObject2,nil];
[metadata setValue:streams forKey:@"stream"];

NSString *imagePath = [[NSBundle bundleForClass:[self class]] pathForResource:@"sample" ofType:@"png"];
NSData *imageData = [NSData dataWithContentsOfFile:imagePath];

[[[OlapicSDK sharedOlapicSDK] uploaders] uploadMediaFromUploader:uploaderEntityObject
                                         imageData:imageData
                                         metadata:metadata
                                         onSuccess:^(OlapicMediaEntity *media){
                                             // Done! The image should appear on the MQ
                                         }
                                         onFailure:^(NSError *error){
                                             NSLog(@"Error: %@",error.description);
                                         }];

Declared In

OlapicUploaderHandler.h

uploadMediaFromUploader:imageData:metadata:onSuccess:onFailure:onProgress:

Upload a media object and track the upload progresss

- (void)uploadMediaFromUploader:(OlapicUploaderEntity *)uploader imageData:(NSData *)imageData metadata:(NSDictionary *)metadata onSuccess:(void ( ^ ) ( OlapicMediaEntity *media ))success onFailure:(void ( ^ ) ( NSError *error ))failure onProgress:(void ( ^ ) ( float progress ))progress

Parameters

uploader

The uploader entity that will ‘own’ the media

imageData

The image to upload, on data format

metadata

The media information

  • NSString caption -required
  • NSString latitude -optional
  • NSString longitude -optional
  • NSArray stream -stream
success

A callback block for when the media is successfully uploaded

failure

A callback block for when the media can’t be uploaded

progress

A callback block that can be used to track the upload progress

Availability

v1.0

Discussion

Example:

NSMutableDictionary *metadata = [[NSMutableDictionary alloc] init];
// Required
[metadata setValue:@"A brief description for the photo" forKey:@"caption"];
// Optional
// - Location
[metadata setValue:@"latitude" forKey:@"latitude"];
[metadata setValue:@"longitude" forKey:@"longitude"];
// - Streams
NSArray *streams = [[NSArray alloc] initWithObjects:streamEntityObject1,streamEntityObject2,nil];
[metadata setValue:streams forKey:@"stream"];

NSString *imagePath = [[NSBundle bundleForClass:[self class]] pathForResource:@"sample" ofType:@"png"];
NSData *imageData = [NSData dataWithContentsOfFile:imagePath];

[[[OlapicSDK sharedOlapicSDK] uploaders] uploadMediaFromUploader:uploaderEntityObject
                                         imageData:imageData
                                         metadata:metadata
                                         onSuccess:^(OlapicMediaEntity *media){
                                             // Done! The image should appear on the MQ
                                         }
                                         onFailure:^(NSError *error){
                                             NSLog(@"Error: %@",error.description);
                                         }
                                         onProgress:^(float progress){
                                             NSLog(@"Progress: %%@",(progress/100));
                                         }];

Declared In

OlapicUploaderHandler.h