我使用谷歌云上传器(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);
}];
}
我收到来自google cloud storage 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."
}
任何人都可以帮助我吗?
答案 0 :(得分:1)
我假设你正在使用iOS密钥。对于这个特定的用例,这实际上并不正确。我知道在iOS应用程序中使用iOS密钥似乎显然是正确的,但奇怪的是它不是。
这里有一个很好的答案,解释了该怎么做:Getting status "REQUEST_DENIED" after fetching data from google places API