【问题标题】:Google Drive iOS SDK file thumbnailLink fails with 404 errorGoogle Drive iOS SDK 文件缩略图链接失败并出现 404 错误
【发布时间】:2013-12-18 21:39:59
【问题描述】:

在我的应用程序中,当我使用 GTLDriveFile 的 thumbnailLink 下载文件的缩略图时,它失败并出现 not-found-on-the-server 错误(代码 404)。以下是 Google Drive iOS SDK 提供的文件 thumbnailLink URL 示例:

https://lh5.googleusercontent.com/eR-ahfZKPGcrqzhfh8Y4_tr7nwpdIdbkPxo19tjBeVPh0gE-QKSdT4fJrg8ajNhQ6g=s220

另外,我注意到 MS Word、MS Excel 和 MS Powerpoint 文件的 URL 最常失败;虽然它们适用于 PDF、png 文件和各种其他文件类型。

还有其他人看到同样的问题吗?你是怎么解决的?

【问题讨论】:

标签: 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 ];
     } ];

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-09-24
    • 1970-01-01
    • 2016-08-02
    • 2011-12-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多