AWSLocalContent Class Reference

Inherits from AWSContent : NSObject
Declared in AWSContentManager.m
AWSUserFileManager.h

Overview

A representation of the local content that may not exist in the Amazon S3 bucket yet. When uploading data to an S3 bucket, you first need to create an instance of this class.

– uploadWithPinOnCompletion:progressBlock:completionHandler:

Uploads data associated with the local content.

- (void)uploadWithPinOnCompletion:(BOOL)pinOnCompletion progressBlock:(void ( ^ ) ( AWSLocalContent *content , NSProgress *progress ))progressBlock completionHandler:(void ( ^ ) ( AWSLocalContent *content , NSError *error ))completionHandler

Parameters

pinOnCompletion

When set to YES, it pins the content after finishing uploading it.

progressBlock

The upload progress block.

completionHandler

The completion handler block.

Discussion

Swift

func uploadWithData(data: NSData, forKey key: String) {

    let userFilemanager = AWSUserFileManager(forKey: "KeyUsedToRegister")
    let localContent = userFilemanager.localContentWithData(data, key: key)
    localContent.uploadWithPinOnCompletion(false, progressBlock: {(content: AWSLocalContent?, progress: NSProgress?) -> Void in
        // handle progress here
        }, completionHandler: {(content: AWSContent?, error: NSError?) -> Void in
            if let error = error {
                // handle error here
                print("Error occured in uploading: \(error)")
                return
            }
            // handle successful upload here
        })
}

Objective-C

- (void)uploadWithData:(NSData *)data forKey:(NSString *)key {

    AWSUserFileManager *userFileManager = [AWSUserFileManager userFileManagerForKey:@"KeyUsedToRegister"];
    AWSLocalContent *localContent = [self.manager localContentWithData:data
                                                                   key:key];
    [localContent uploadWithPinOnCompletion:NO
                              progressBlock:^(AWSLocalContent *content, NSProgress *progress) {
                                // handle progress here
                              }
                              completionHandler:^(AWSContent *content, NSError *error) {
                                if (error) {
                                    // handle error here
                                    NSLog(@"Error occured in uploading: %@", error);
                                    return;
                                }
                                // perform tasks after successful upload
                              }];
}

Declared In

AWSUserFileManager.h