ios - 谷歌云存储 JSON uploader api 显示错误

标签 ios google-cloud-storage

我正在使用 google cloud uploader ( https://developers.google.com/storage/docs/json_api/v1/how-tos/upload ) API 从 IOS 上传图片。

我有以下代码。对于 REST 管理器,我使用此处的代码 https://github.com/SSamanta/SSRestClient

+(void)uploadData:(NSData *)data withName:(NSString *)name onCompletion:(ServiceCompletionHandler)handler {
    SSRestManager *restManager = [[SSRestManager alloc] init];
    restManager.httpMethod = @"POST";
    restManager.contentType = @"image/jpeg";
    restManager.contentLength = [NSString stringWithFormat:@"%i",data.length];
    restManager.httpBody = data;
    NSString *urlString = [NSString stringWithFormat:@"https://www.googleapis.com/upload/storage/v1beta2/b/videosbetas/o?uploadType=media&name=myObject&key=%@",kAPIKey];
    [restManager getHttpResponseWithBaseUrl:urlString onCompletion:^(id responseData, NSURLResponse *reponse) {
        if (responseData) {
            handler (responseData,nil);
        }
    } onError:^(NSError *error) {
        handler(nil,error);
    }];
}

我从谷歌云存储 API 收到以下错误消息。我已按照所有说明在谷歌开发者控制台中配置应用程序。

{
 "error": {
  "errors": [
   {
    "domain": "usageLimits",
    "reason": "accessNotConfigured",
    "message": "Access Not Configured. Please use Google Developers Console to activate the API for your project."
   }
  ],
  "code": 403,
  "message": "Access Not Configured. Please use Google Developers Console to activate the API for your project."
 }

谁能帮帮我?

最佳答案

我假设您使用的是 iOS key 。对于这个特定的用例,这实际上是不正确的。我知道为 iOS 应用程序使用 iOS key 显然是正确的,但奇怪的是事实并非如此。

这里有一个很好的答案,解释了该怎么做:Getting status "REQUEST_DENIED" after fetching data from google places API

关于ios - 谷歌云存储 JSON uploader api 显示错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23288094/

相关文章:

iphone - 如何检查用户是否已在我的iPhone应用程序中订阅

google-cloud-storage - 如何上传文件到云存储?

iphone - 使用 NSRegularExpression 提取文本

ios - 不兼容的整数到指针的转换将 'NSInteger'(又名 'int')发送到类型为 'NSInteger *'(又名 'int *')的参数

html - 谷歌地图在 iOS 上通过框溢出

android - 条码扫描坏了

apache-spark - 无法将 spark 数据帧写入 gcs 存储桶

java - App Engine 云存储 RequestPayloadTooLargeException 文件超出 10 MB 限制

kubernetes - 我正在尝试使用 gcs 存储桶作为 gke pod 中的卷

android - Android 应用程序的云数据库