ios应用程序的HTTP GET请求使用哪个API密钥

2024-03-28 16:03:43 发布

您现在位置:Python中文网/ 问答频道 /正文

在这一页上,https://cloud.google.com/storage/docs/json_api/v1/objects/get#http-request

它允许您输入bucket的名称和要下载的对象的名称。它返回一个200响应和所有的对象元数据,并显示它使用的确切url。你知道吗

获取https://www.googleapis.com/storage/v1/b/bucket/o/object?key={你的API\u密钥}

有多个api密钥。IOS API。服务器API密钥。浏览器API密钥

我用什么。因为如果我获取他们使用的url,并将iosapi密钥放入这里的代码中

//1
    let filePath = "https://www.googleapis.com/storage/v1/b/bucket/o/object?key={YOUR_API_KEY}"
    let fileUrl = NSURL(string: filePath)

    // 2
    let downloadTask: NSURLSessionDownloadTask = NSURLSession.sharedSession().downloadTaskWithURL(fileUrl!) { (location: NSURL?, response: NSURLResponse?, error: NSError?) in
        let downloadedImage: UIImage = UIImage(data: NSData(contentsOfURL: location!)!)!
        cardView.image = downloadedImage
    }

    downloadTask.resume()

并将其替换为我的bucket名称、object名称以及iosapi密钥。我将得到一个401未经授权或致命错误发现零。你知道吗

我做错什么了?你知道吗


Tags: 对象https名称comapiurlobjectbucket