Note that there are some explanatory texts on larger screens.

plurals
  1. POCan anyone help to figure out how to upload a file to window azure server using objective c
    primarykey
    data
    text
    <p>I want to upload a file to window azure storage using accountkey and account name. Can anyone help me to achieve this in objective c.</p> <p>i tried the code </p> <p>NSString *urlString = :@"https://myaccount.blob.core.windows.net/coretest";</p> <pre><code>NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease]; [request setURL:[NSURL URLWithString:urlString]]; [request setHTTPMethod:@"POST"]; NSString *boundary = [NSString stringWithString:@"0xLhTaLbOkNdArZ"]; //Reading the file NSString *filePath = @"/Users/rcj/Documents/Xcode.rtf"; NSLog(@"file Path to upload: %@",filePath); NSData *myData = [NSData dataWithContentsOfFile:filePath]; NSMutableData *body = [NSMutableData data]; [body appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n",boundary] dataUsingEncoding:NSUTF8StringEncoding]]; [body appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"userfile\"; filename=\"Xcode.rtf\"\r\n"] dataUsingEncoding:NSUTF8StringEncoding]]; [body appendData:[[NSString stringWithString:@"Content-Type: application/octet-stream\r\n\r\n"] dataUsingEncoding:NSUTF8StringEncoding]]; [body appendData:myData]; [body appendData:[[NSString stringWithFormat:@"\r\n--%@--\r\n",boundary] dataUsingEncoding:NSUTF8StringEncoding]]; NSDate *now = [[NSDate alloc] init]; NSString *dateString = [self rfc1123String:now]; NSString *AZURE_ACCOUNT_NAME = @"myaccount"; NSString *password = @"xxxxxxxxxxxxxxxxxxxxxxxxxxx=="; [request addValue:[NSString stringWithFormat:@"SharedKey %@:%@",AZURE_ACCOUNT_NAME, password] forHTTPHeaderField:@"Authorization"]; [request addValue:dateString forHTTPHeaderField:@"x-ms-date"]; [request addValue:@"application/atom+xml, application/xml"forHTTPHeaderField:@"Accept"]; [request addValue:@"UTF-8" forHTTPHeaderField:@"Accept-Charset"]; [request setHTTPBody:body]; NSLog(@"Headers: %@", [request allHTTPHeaderFields]); NSLog(@"URL: %@", [[request URL] absoluteString]); connection =[[NSURLConnection alloc] initWithRequest:request delegate:self]; if(connection) { receivedData = [[NSMutableData data] retain]; } else { // Inform the user that the con } </code></pre> <p>Thanks RCJ</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload