为了获取不同文件的MIMEType,特意抽取了一个工具类,希望对大家有帮助:
- (NSString *)MIMEType:(NSURL *)url { //1.创建一个请求 NSURLRequest *request = [NSURLRequest requestWithURL:url]; //2.发送请求(返回响应) NSURLResponse *response = nil; [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:nil]; //3.获得MIMEType return response.MIMEType; }