yellow
yellow

Reputation: 702

Any iOS core lib can upload blob to windows azure storage?

Windows azure SDK-ios only for mobileService,I want to upload something to storage in iOS app.

Have any core lib to do this?

Upvotes: 2

Views: 1630

Answers (2)

Chris
Chris

Reputation: 3017

Take a look at this walkthrough: http://chrisrisner.com/Mobile-Services-and-Windows-Azure-Storage. It details how to use Mobile Services to generate a Secure Access Signature which you can hand back to your iOS app to use to upload to blob storage. This prevents you from needing to keep the storage account name and key in your client application.

Upvotes: 2

melgamal
melgamal

Reputation: 101

Try this

UIImage *img = self.imageItem.image;
    NSData *imageData = UIImageJPEGRepresentation(img, 0.5);

    NSMutableURLRequest* theRequest = [NSMutableURLRequest requestWithURL: [NSURL URLWithString: {replace with the storage url you are uploading to}  ] ];
    [theRequest setHTTPMethod: @"PUT"];
    [theRequest setHTTPBody: imageData];
    [theRequest setValue:@"image/PNG" forHTTPHeaderField:@"Content-Type"];
    [theRequest setValue:@"BlockBlob"  forHTTPHeaderField:@"x-ms-blob-type"];
    [theRequest setValue:[NSString stringWithFormat:@"%d", [imageData length]] forHTTPHeaderField:@"Content-Length"];
    NSData *response;
    NSError *WSerror;
    NSURLResponse *WSresponse;
    NSString *responseString;
    response = [NSURLConnection sendSynchronousRequest:theRequest returningResponse:&WSresponse error:&WSerror];
    responseString = [[NSString alloc] initWithData:response encoding:NSUTF8StringEncoding] ;

Upvotes: 2

Related Questions