【问题标题】:Google Drive iOS SDK file thumbnailLink fails with 404 errorGoogle Drive iOS SDK 文件缩略图链接失败并出现 404 错误
【发布时间】:2013-12-18 21:39:59
【问题描述】:
【问题讨论】:
标签:
ios
http-status-code-404
thumbnails
google-drive-api
【解决方案1】:
GTLServiceDrive * 服务...
试试
- (void)authorizeRequest:(NSMutableURLRequest *)request
completionHandler:(void (^)(NSError *error))handler
例子:
NSURL * url = [ NSURL URLWithString:thumbnailLink ];
NSMutableURLRequest * request = [ NSMutableURLRequest requestWithURL:url ];
[ service.authorizer authorizeRequest:request completionHandler:^(NSError *error)
{
NSURLSession * defaultSession = [ NSURLSession sessionWithConfiguration:[ NSURLSessionConfiguration defaultSessionConfiguration ]
delegate:nil
delegateQueue:[ NSOperationQueue mainQueue ] ];
NSURLSessionDataTask * dataTask = [ defaultSession dataTaskWithRequest:request
completionHandler:^(NSData * data, NSURLResponse * response, NSError * error)
{
NSHTTPURLResponse * httpResponse = (NSHTTPURLResponse *)response;
if ([ httpResponse isKindOfClass:[ NSHTTPURLResponse class ] ] && httpResponse.statusCode == 200 && data)
{
UIImage * image = [ UIImage imageWithData:data ];
...
}
} ];
[ dataTask resume ];
} ];