Note that there are some explanatory texts on larger screens.

plurals
  1. POIssue in posting an audio file to a web server through a NSURLRequest and retrieving it back
    primarykey
    data
    text
    <p>I am coding an application that needs to send audio files, in mp3 or any other common audio format, to a server. I am using a <code>NSURLConnection</code> instance to make this connection. I'm using the post method because the file that receives the information is a .php. In the same connection I need to send other parameters that are mostly strings and ints. The problem that I am facing is actually sending the audio file and receiving it in the server. I'm using the next code to build my connection:</p> <pre><code>NSMutableURLRequest *localRequest = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:@"whateverphpfile"]]; [localRequest setHTTPMethod:@"POST"]; [self setRequest:localRequest]; [localRequest release]; NSMutableData *body = [[NSMutableData alloc] init]; NSString *testerSTR = [NSString stringWithFormat:@"file=%@", [[NSBundle mainBundle] pathForResource:@"header" ofType:@"png"]]; [body setData:[testerSTR dataUsingEncoding:NSUTF8StringEncoding]]; //_request is of type NSMutableURLRequest [_request setHTTPBody:body]; //[_request setValue:@"multipart/form-data" forHTTPHeaderField:@"enctype"]; [_request setValue:@"multipart/form-data" forHTTPHeaderField:@"content-type"]; NSLog(@"the body sent is: %@", [[NSString alloc] initWithData:body encoding:NSUTF8StringEncoding]); _connection = [[NSURLConnection alloc] initWithRequest:_request delegate:self]; if (_connection) { [self setWebData:[NSMutableData data]]; } else { NSLog(@"theConnection is NULL"); } </code></pre> <p>and the problem when checking the data and returning it to the device is that it is a laaarge string like <code>&lt;564024S D451475 DS5752... ...552D4S5&gt;</code>. What should I do to receive the actual audio file or how can I transform that large string into an audio file readable by the native iOS classes?</p>
    singulars
    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.
 

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