我正在使用谷歌 Cloud 上传器(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);
}];
}
我收到来自谷歌 Cloud 存储API的以下错误消息 . 我已按照所有说明在Google开发者控制台中配置应用 .
{
"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."
}
谁能帮我?
1 回答
我假设您使用的是iOS密钥 . 对于这个特定的用例,这实际上并不正确 . 我知道在iOS应用程序中使用iOS密钥似乎显然是正确的,但奇怪的是它不是 .
这里有一个很好的答案,解释了该怎么做:Getting status "REQUEST_DENIED" after fetching data from google places API