0
votes

On this page, https://cloud.google.com/storage/docs/json_api/v1/objects/get#http-request

It allows you to input the name of your bucket and the name of the object that you would like to download. It returns with a 200 Response and all of the objects metadata as well as shows you the exact url that it used.

GET https://www.googleapis.com/storage/v1/b/bucket/o/object?key={YOUR_API_KEY}

There are muliple api keys. IOS API. SERVER API KEY. BROWSER API KEY

What do I use. Becasue if i take the url that they used, and put in the IOS API key into this code here

//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()

And replace it with my bucket name and object name as well as the ios API key. I will get either a 401 unauthorized or fatal error found nil.

What am i doing wrong?

1

1 Answers

0
votes

The IOS API should be used with the iOS SDK. If you are requesting the URL directly, i think that you should use the server or browser API.