title: iOS: Get file's metadata
body: <p>I have an mp3 file on a server. I want to get this file's information like what's the size of this file, what's the artists name, what's the album name, when was the file created, when was it modified, etc. I want all this information.</p>
  
  <p>Is it possible to get this information without actually downloading the whole file? Using <code>NSURLConnection</code> or otherwise?</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>The following code doesn't give me the required information, i.e. file created by, artist name, etc</p>
  
  <pre><code>    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:&amp;response error:&amp;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]);
      }
  </code></pre>
  
  <p>The "AllHeaderFields" is:</p>
  
  <pre><code>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";
  }
  </code></pre>