accountkey とアカウント名を使用して、window azure ストレージにファイルをアップロードしたいと考えています。目標cでこれを達成するのを手伝ってくれる人はいますか。
私はコードを試しました
NSString *urlString = :@"https://myaccount.blob.core.windows.net/coretest";
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
}
ありがとうRCJ