BuiltUpload Class Reference

Inherits from NSObject
Declared in BuiltUpload.h

Properties

  fileName

the filename of the uploaded file

 //assuming 'uploadObject' is BuiltUpload instance

 //Obj-C
 NSString *uploadedFileName = uploadObject.fileName;

 //Swift
 var uploadedFileName:String = uploadObject.fileName
@property (nonatomic, copy, readonly) NSString *fileName

Declared In

BuiltUpload.h

  filesize

the filesize of the uploaded file

 //assuming 'uploadObject' is BuiltUpload instance

 //Obj-C
 unsigned int fileSize = uploadObject.filesize;

 //Swift
 var fileSize:UInt32 = uploadObject.filesize
@property (nonatomic, assign, readonly) unsigned int filesize

Declared In

BuiltUpload.h

  contentType

the contentType of the uploaded file

 //assuming 'uploadObject' is BuiltUpload instance

 //Obj-C
 NSString *contentType = [uploadObject contentType];

 //Swift
 var contentType:String = uploadObject.contentType
@property (nonatomic, copy, readonly) NSString *contentType

Declared In

BuiltUpload.h

  uid

the uid of the uploaded file

 //assuming 'uploadObject' is BuiltUpload instance

 //Obj-C
 NSString *uploadedFileUID = [uploadObject uid];

 //Swift
 var uploadedFileUID:String = uploadObject.uid
@property (nonatomic, copy, readonly) NSString *uid

Declared In

BuiltUpload.h

  tags

the tags associated with the uploaded file

 //'blt5d4sample2633b' is a dummy Application API key

 //Obj-C
 BuiltApplication *builtApplication = [Built applicationWithAPIKey:@"blt5d4sample2633b"];
 BuiltUpload *uploadObject = [builtApplication upload];

 //setting tags
 uploadObject.tags = @[@"pic", @"photo"];

 //getting tags
 NSArray *tagFileArray = [uploadObject tags];

 //Swift
 var builtApplication:BuiltApplication = Built.applicationWithAPIKey("blt5d4sample2633b")
 var uploadObject:BuiltUpload = builtApplication.upload()

 //setting tags
 uploadObject.tags = ["pic", "photo"]

 //getting tags
 var tagFileArray:AnyObject! = uploadObject.tags
@property (nullable, nonatomic, copy) NSArray *tags

Declared In

BuiltUpload.h

  ACL

the ACL applied to the uploaded file

 //'blt5d4sample2633b' is a dummy Application API key

 //Obj-C
 BuiltApplication *builtApplication = [Built applicationWithAPIKey:@"blt5d4sample2633b"];
 BuiltUpload *uploadObject = [builtApplication upload];
 BuiltACL *acl = [uploadObject ACL];

 //Swift
 var builtApplication:BuiltApplication = Built.applicationWithAPIKey("blt5d4sample2633b")
 var uploadObject:BuiltUpload = builtApplication.upload()
 var acl:BuiltACL = uploadObject.ACL
@property (nonatomic, strong) BuiltACL *ACL

Declared In

BuiltUpload.h

  url

the url of the uploaded file

 //'blt5d4sample2633b' is a dummy Application API key

 //Obj-C
 NSString *profileImageURL = [uploadObject url];

 //Swift
 var profileImageURL:String = uploadObject.url
@property (nonatomic, copy, readonly) NSString *url

Declared In

BuiltUpload.h

  enableCache

enable/disable file cache

 //'blt5d4sample2633b' is a dummy Application API key

 //Obj-C
 BuiltApplication *builtApplication = [Built applicationWithAPIKey:@"blt5d4sample2633b"];
 BuiltUpload *uploadObject = [builtApplication upload];

 //to set value
 uploadObject.enableCache = YES;

 //to check value
 if ([uploadObject isCachingEnabled]) {
    //caching is enabled
 } else {
    //caching is disabled
 }

 //Swift
 var builtApplication:BuiltApplication = Built.applicationWithAPIKey("blt5d4sample2633b")
 var uploadObject:BuiltUpload = builtApplication.upload()

 //to set value
 uploadObject.enableCache = true

 //to check value
 if (uploadObject.isCachingEnabled()) {
    //caching is enabled
 } else {
    //caching is disabled
 }
@property (nonatomic, assign, getter=isCachingEnabled) BOOL enableCache

Declared In

BuiltUpload.h

Attaching/Removing Headers.

– setHeader:forKey:

Additional headers if required

 //'blt5d4sample2633b' is a dummy Application API key

 //Obj-C
 BuiltApplication *builtApplication = [Built applicationWithAPIKey:@"blt5d4sample2633b"];
 BuiltUpload *uploadObject = [builtApplication upload];
 [uploadObject setHeader:@"MyHeaderValue" forKey:@"My-Custom-Header-Key"];

 //Swift
 var builtApplication:BuiltApplication = Built.applicationWithAPIKey("blt5d4sample2633b")
 var uploadObject:BuiltUpload = builtApplication.upload()
 uploadObject.setHeader("MyHeaderValue", forKey:"My-Custom-Header-Key")
- (void)setHeader:(NSString *)header forKey:(NSString *)key

Parameters

header

header value

key

header key

Declared In

BuiltUpload.h

– removeHeaderForKey:

Remove a header for a specific key

 //'blt5d4sample2633b' is a dummy Application API key

 //Obj-C
 BuiltApplication *builtApplication = [Built applicationWithAPIKey:@"blt5d4sample2633b"];
 BuiltUpload *uploadObject = [builtApplication upload];
 [uploadObject removeHeaderForKey:@"My-Custom-Header-Key"];

 //Swift
 var builtApplication:BuiltApplication = Built.applicationWithAPIKey("blt5d4sample2633b")
 var uploadObject:BuiltUpload = builtApplication.upload()
 uploadObject.removeHeaderForKey("My-Custom-Header-Key")
- (void)removeHeaderForKey:(NSString *)key

Parameters

key

Key for which to remove the header value

Declared In

BuiltUpload.h

Add file/data/image for uploading

– setFilepath:withFileName:

set file to be uploaded

 //'blt5d4sample2633b' is a dummy Application API key

 //Obj-C
 BuiltApplication *builtApplication = [Built applicationWithAPIKey:@"blt5d4sample2633b"];
 BuiltUpload *uploadObject = [builtApplication upload];
 NSString *imageFilePath = [[NSBundle mainBundle] pathForResource:@"profileimage" ofType:@"png"];
 [uploadObject setFilepath:imageFilePath withFileName:@"profile"];

 //Swift
 var builtApplication:BuiltApplication = Built.applicationWithAPIKey("blt5d4sample2633b")
 var uploadObject:BuiltUpload = builtApplication.upload()
 var imageFilePath:NSString = NSBundle.mainBundle().pathForResource("profileimage", ofType: "png")
 uploadObject.setFilepath(imageFilePath, withFileName:"profile")
- (void)setFilepath:(NSString *)filePath withFileName:(NSString *)key

Parameters

filePath

path of the file from NSBundle

key

add file against a key.

Declared In

BuiltUpload.h

– setData:forKey:

set data of file to be uploaded

 //'blt5d4sample2633b' is a dummy Application API key

 //Obj-C
 BuiltApplication *builtApplication = [Built applicationWithAPIKey:@"blt5d4sample2633b"];
 BuiltUpload *uploadObject = [builtApplication upload];
 NSString *imageFilePath = [[NSBundle mainBundle] pathForResource:@"profileimage" ofType:@"png"];
 NSData *myData = [NSData dataWithContentsOfFile:imageFilePath];
 [uploadObject setData:myData forKey:@"profile"];

 //Swift
 var builtApplication:BuiltApplication = Built.applicationWithAPIKey("blt5d4sample2633b")
 var uploadObject:BuiltUpload = builtApplication.upload()
 var imageFilePath:NSString = NSBundle.mainBundle().pathForResource("profileimage", ofType: "png")
 var myData = NSData(contentsOfFile:imageFilePath)
 uploadObject.setData(myData, forKey:"profile")
- (void)setData:(NSData *)data forKey:(NSString *)key

Parameters

data

NSData representation of any object to be uploaded

key

add data against a key.

Declared In

BuiltUpload.h

– configureWithDictionary:

Accepts NSDictionary insance as parameter to configure upload object.

- (void)configureWithDictionary:(NSDictionary *)dictionary

Parameters

dictionary

json response data to configure

Discussion

 //'blt5d4sample2633b' is a dummy Application API key

 //Obj-C
 BuiltApplication *builtApplication = [Built applicationWithAPIKey:@"blt5d4sample2633b"];
 BuiltUpload *uploadObject = [builtApplication upload];
 [uploadObject configureWithDictionary:@{@"my property":@"property_key", @"my property":@"property_key"}];

 //Swift
 var builtApplication:BuiltApplication = Built.applicationWithAPIKey("blt5d4sample2633b")
 var uploadObject:BuiltUpload = builtApplication.upload()
 uploadObject.configureWithDictionary(["my property":"property_key", "my property":"property_key"])

Declared In

BuiltUpload.h

– setImage:forKey:

set image file to be uploaded

 //'blt5d4sample2633b' is a dummy Application API key

 //Obj-C
 BuiltApplication *builtApplication = [Built applicationWithAPIKey:@"blt5d4sample2633b"];
 BuiltUpload *uploadObject = [builtApplication upload];
 UIImage *image = [UIImage imageNamed:@"profileimage"];
 [uploadObject setImage:image forKey:@"profile"];

 //Swift
 var builtApplication:BuiltApplication = Built.applicationWithAPIKey("blt5d4sample2633b")
 var uploadObject:BuiltUpload = builtApplication.upload()
 var image = UIImage(named:"profileimage")
 uploadObject.setImage(image, forKey:"profile")
- (void)setImage:(UIImage *)image forKey:(NSString *)key

Parameters

image

UIImage object to be uploaded

key

add image against a key.

Declared In

BuiltUpload.h

– removeAttachedFile

remove attacted file for upload.

 //'blt5d4sample2633b' is a dummy Application API key

 //Obj-C
 BuiltApplication *builtApplication = [Built applicationWithAPIKey:@"blt5d4sample2633b"];
 BuiltUpload *uploadObject = [builtApplication upload];
 [uploadObject removeAttachedFile];

 //Swift
 var builtApplication:BuiltApplication = Built.applicationWithAPIKey("blt5d4sample2633b")
 var uploadObject:BuiltUpload = builtApplication.upload()
 uploadObject.removeAttachedFile()
- (void)removeAttachedFile

Declared In

BuiltUpload.h

Save files with Built.io Backend

– save:

Upload one or more images/files to Built.io Backend asynchronously.

 //'blt5d4sample2633b' is a dummy Application API key

 //Obj-C
 BuiltApplication *builtApplication = [Built applicationWithAPIKey:@"blt5d4sample2633b"];
 BuiltUpload *uploadObject = [builtApplication upload];
 [uploadObject save:^(BuiltResponseType responseType, NSError *error) {

 }];

 //Swift
 var builtApplication:BuiltApplication = Built.applicationWithAPIKey("blt5d4sample2633b")
 var uploadObject:BuiltUpload = builtApplication.upload()
 uploadObject.save { (responseType, error) -> Void in

 }
- (void)save:(BuiltRequestCompletionHandler)completionBlock

Parameters

completionBlock

Completion block with params responseType (cache or network) and error object in any.

Declared In

BuiltUpload.h

– destroy:

Deletes the upload with specified UID asynchronously.

 //'blt5d4sample2633b' is a dummy Application API key

 //Obj-C
 BuiltApplication *builtApplication = [Built applicationWithAPIKey:@"blt5d4sample2633b"];
 BuiltUpload *uploadObject = [builtApplication upload];
 [uploadObject destroy:^(BuiltResponseType responseType, NSError *error) {

 }];

 //Swift
 var builtApplication:BuiltApplication = Built.applicationWithAPIKey("blt5d4sample2633b")
 var uploadObject:BuiltUpload = builtApplication.upload()
 uploadObject.destroy { (responseType, error) -> Void in

 }
- (void)destroy:(BuiltRequestCompletionHandler)completionBlock

Parameters

completionBlock

Completion block with params responseType (cache or network) and error object in any.

Declared In

BuiltUpload.h

– fetch:

Fetches a file asynchronously when provided UID.

 //'blt5d4sample2633b' is a dummy Application API key

 //Obj-C
 BuiltApplication *builtApplication = [Built applicationWithAPIKey:@"blt5d4sample2633b"];
 BuiltUpload *uploadObject = [builtApplication upload];
 [uploadObject fetch:^(BuiltResponseType responseType, NSError *error) {

 }];

 //Swift
 var builtApplication:BuiltApplication = Built.applicationWithAPIKey("blt5d4sample2633b")
 var uploadObject:BuiltUpload = builtApplication.upload()
 uploadObject.fetch { (responseType, error) -> Void in

 }
- (void)fetch:(BuiltRequestCompletionHandler)completionBlock

Parameters

completionBlock

Completion block with params responseType (cache or network) and error object in any.

Declared In

BuiltUpload.h

– downloadImage:

if an upload contains an image, use this method to download the image asynchronously.

 //'blt5d4sample2633b' is a dummy Application API key

 //Obj-C
 BuiltApplication *builtApplication = [Built applicationWithAPIKey:@"blt5d4sample2633b"];
 BuiltUpload *uploadObject = [builtApplication upload];
 [uploadObject downloadImage:^(BuiltResponseType responseType, UIImage *image, NSError *error) {

 }];

 //Swift
 var builtApplication:BuiltApplication = Built.applicationWithAPIKey("blt5d4sample2633b")
 var uploadObject:BuiltUpload = builtApplication.upload()
 uploadObject.downloadImage { (responseType, image, error) -> Void in

 }
- (void)downloadImage:(void ( ^ ) ( BuiltResponseType responseType , UIImage *BUILT_NULLABLE_P image , NSError *BUILT_NULLABLE_P error ))completionBlock

Parameters

completionBlock

Completion block with params responseType (cache or network), image and error object in any.

Declared In

BuiltUpload.h

– downloadData:

if an upload contains a file other than image, use this method to download the file asynchronously.

 //'blt5d4sample2633b' is a dummy Application API key

 //Obj-C
 BuiltApplication *builtApplication = [Built applicationWithAPIKey:@"blt5d4sample2633b"];
 BuiltUpload *uploadObject = [builtApplication upload];
 [uploadObject downloadData:^(BuiltResponseType responseType, NSData *data, NSError *error) {

 }];

 //Swift
 var builtApplication:BuiltApplication = Built.applicationWithAPIKey("blt5d4sample2633b")
 var uploadObject:BuiltUpload = builtApplication.upload()
 uploadObject.downloadData { (responseType, data, error) -> Void in

}

- (void)downloadData:(void ( ^ ) ( BuiltResponseType responseType , NSData *BUILT_NULLABLE_P data , NSError *BUILT_NULLABLE_P error ))completionBlock

Parameters

completionBlock

on successful download, the data param will contain NSData object.

Declared In

BuiltUpload.h

Cancel

– cancel

cancel ongoing file uploading network requests

 //'blt5d4sample2633b' is a dummy Application API key

 //Obj-C
 BuiltApplication *builtApplication = [Built applicationWithAPIKey:@"blt5d4sample2633b"];
 BuiltUpload *uploadObject = [builtApplication upload];
 [uploadObject cancel];

 //Swift
 var builtApplication:BuiltApplication = Built.applicationWithAPIKey("blt5d4sample2633b")
 var uploadObject:BuiltUpload = builtApplication.upload()
 uploadObject.cancel()
- (void)cancel

Declared In

BuiltUpload.h

Realtime Methods

– on:callback:

Registers a event listener on Upload in general or in particular depending on implementation.

- (void)on:(BuiltRealtimeEventType)eventType callback:(EventCallback)callback

Parameters

eventType

event types i.e Create/Upate/Delete/Broadcast explained above

callback

response object if success or error object

Discussion

For list of supported events, check BuiltRealtimeEventType

 //ObjC
 BuiltApplication *builtApplication = [Built applicationWithAPIKey:@"blt5d4sample2633b"];
 BuiltClass *projectClass = [builtApplication classWithUID:@"project"];
 BuiltUpload *uploadObject = [projectClass upload];

 //just for example we are using BuiltRealtimeEventTypeCreate.
 [uploadObject on:BuiltRealtimeEventTypeCreate callback:^(id response, NSError *error) {
     if (error) {
        //some error occured while listening
     }else {
        //BuiltUpload instance in response which is recently created
     }
 }];

 //Swift
 var builtApplication:BuiltApplication = Built.applicationWithAPIKey("blt5d4sample2633b")
 var projectClass:BuiltClass = builtApplication.classWithUID("project")
 var uploadObject:BuiltUpload = projectClass.upload()

 //just for example we are using BuiltRealtimeEventType.Create.
 uploadObject.on(BuiltRealtimeEventType.Create, callback: { (response, error) -> Void in
     if (error != nil) {
        //some error occured while listening
     }else {
        //BuiltUpload instance in response which is recently created
     }
 })

Warning: Not supported in watchOS

Declared In

BuiltUpload+Realtime.h

– off:callback:

Unregisters event listener(s) from Upload in general or in particular depending on implementation.

- (void)off:(BuiltRealtimeEventType)eventType callback:(EventCallback)callback

Parameters

eventType

Create/Update/Delete/Broadcast

callback

response object if success or error object

Discussion

For list of supported events, check BuiltRealtimeEventType

 //ObjC
 BuiltApplication *builtApplication = [Built applicationWithAPIKey:@"blt5d4sample2633b"];
 BuiltClass *projectClass = [builtApplication classWithUID:@"project"];
 BuiltUpload *uploadObject = [projectClass upload];

 //just for example we are using BuiltRealtimeEventTypeCreate.
 [uploadObject off:BuiltRealtimeEventTypeCreate callback:^(id response, NSError *error) {
     if (error) {
        //some error occured while unregister
     }
 }];

 //Swift
 var builtApplication:BuiltApplication = Built.applicationWithAPIKey("blt5d4sample2633b")
 var projectClass:BuiltClass = builtApplication.classWithUID("project")
 var uploadObject:BuiltUpload = projectClass.upload()

 //just for example we are using BuiltRealtimeEventType.Create.
 uploadObject.off(BuiltRealtimeEventType.Create, callback: { (response, error) -> Void in
     if (error != nil) {
        //some error occured while unregister
     }
 })

Warning: Not supported in watchOS

Declared In

BuiltUpload+Realtime.h

– broadcastWithMessage:callback:

Sending a broadcast message to Upload in general or in particular depending on implementation.

- (void)broadcastWithMessage:(NSString *)message callback:(EventCallback)callback

Parameters

message

message to broadcast

callback

callback called once broadcast message is send if error occurs error object will be received.

Discussion

 // 'blt5d4sample2633b' is dummy Application API key

 //ObjC
 BuiltApplication *builtApplication = [Built applicationWithAPIKey:@"blt5d4sample2633b"];
 BuiltClass *projectClass = [builtApplication classWithUID:@"project"];
 BuiltUpload *uploadObject = [projectClass upload];
 [uploadObject broadcastWithMessage:@"Hello world" callback:^(id response, NSError *error) {
     if (error) {
        // error while sending message
     }else {
        // sent broadcast message successfully
     }
 }];

 //Swift
 var builtApplication:BuiltApplication = Built.applicationWithAPIKey("blt5d4sample2633b")
 var projectClass:BuiltClass = builtApplication.classWithUID("project")
 var uploadObject:BuiltUpload = projectClass.upload()
 uploadObject.broadcastWithMessage("Hello World", callback: { (response, error) -> Void in
 if (error != nil) {
 // error while sending message
 }else {
 // sent broadcast message successfully
 }
 })

Warning: Not supported in watchOS

Declared In

BuiltUpload+Realtime.h