I have an mp3 file on the server. I want to get this information about the file, like the size of this file, artist name, album name, when the file was created, when it was changed, etc. I want all this information.
Is it possible to get this information without actually downloading the entire file? Using NSURLConnectionor otherwise?
EDIT:
The following code does not give me the required information, that is, a file created by the name of the artist, etc.
NSError *rerror = nil;
NSURLResponse *response = nil;
NSURL *url = [NSURL URLWithString:@"http://link.to.mp3"];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
[request setHTTPMethod:@"HEAD"];
NSData *result = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&rerror];
NSString *resultString = [[[NSString alloc] initWithData:result encoding:NSUTF8StringEncoding] autorelease];
NSLog(@"URL: %@", url);
NSLog(@"Request: %@", request);
NSLog(@"Result (NSData): %@", result);
NSLog(@"Result (NSString): %@", resultString);
NSLog(@"Response: %@", response);
NSLog(@"Error: %@", rerror);
if ([response isMemberOfClass:[NSHTTPURLResponse class]]) {
NSLog(@"AllHeaderFields: %@", [((NSHTTPURLResponse *)response) allHeaderFields]);
}
"AllHeaderFields":
AllHeaderFields: {
"Cache-Control" = "max-age=0";
Connection = "keep-alive";
"Content-Encoding" = gzip;
"Content-Type" = "text/plain; charset=ascii";
Date = "Fri, 17 Feb 2012 12:44:59 GMT";
Etag = 19202n;
Pragma = public;
Server = dbws;
"x-robots-tag" = "noindex,nofollow";
}
source
share