iosobjective-camazon-web-servicesmechanicalturkawss3transfermanager

AWS S3 SDKv2 and image upload ios on turk


I uploaded image to AWS S3 with with code :

    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *filePath = [[paths objectAtIndex:0] stringByAppendingPathComponent:pathComp];
    [UIImageJPEGRepresentation(myImage,0.9) writeToFile:filePath atomically:NO];
    filePath = [NSString stringWithFormat:@"file:///private%@", filePath];
    NSURL* fileUrl = [NSURL URLWithString:filePath];
    AWSS3TransferManagerUploadRequest *uploadRequest = [AWSS3TransferManagerUploadRequest new];
    uploadRequest.key = key;
    uploadRequest.body = fileUrl;
    uploadRequest.contentType = @"image/jpeg";

It's uploaded normally, but in mechanical turk i can't open preview

This page contains the following errors:

error on line 1 at column 1: Document is empty
error on line 1 at column 1: Encoding error
Below is a rendering of the page up to the first error. 

Solution

  • Finded solution for AWS SDK v2 by PaulTaykalo

    https://github.com/aws/aws-sdk-ios/issues/10
    

    Link for fixed method http://pastie.org/9340740

    Also added this code to swizzled method

    [headers setValue:contentType forKey:@"Content-Type"];