Retrieves a list of objects in the Google Cloud Storage bucket. The name of the bucket is specified in the URL's path. This example retrieves a listing of the objects in the "chilkat-test" bucket.
curl -X GET https://www.googleapis.com/storage/v1/b/chilkat-bucket/o?project=MY_CLOUD_STORAGE_PROJECT \
--header "Authorization: Bearer CLOUD_STORAGE_TOKEN"
Dim rest As New Chilkat.Rest
Dim success As Boolean
// URL: https://www.googleapis.com/storage/v1/b/chilkat-bucket/o?project=MY_CLOUD_STORAGE_PROJECT
Dim bTls As Boolean
bTls = True
Dim port As Int32
port = 443
Dim bAutoReconnect As Boolean
bAutoReconnect = True
success = rest.Connect("www.googleapis.com",port,bTls,bAutoReconnect)
If (success <> True) Then
System.DebugLog("ConnectFailReason: " + Str(rest.ConnectFailReason))
System.DebugLog(rest.LastErrorText)
Return
End If
success = rest.AddHeader("Authorization","Bearer CLOUD_STORAGE_TOKEN")
Dim sbResponseBody As New Chilkat.StringBuilder
success = rest.FullRequestNoBodySb("GET","/storage/v1/b/chilkat-bucket/o?project=MY_CLOUD_STORAGE_PROJECT",sbResponseBody)
If (success <> True) Then
System.DebugLog(rest.LastErrorText)
Return
End If
Dim respStatusCode As Int32
respStatusCode = rest.ResponseStatusCode
If (respStatusCode >= 400) Then
System.DebugLog("Response Status Code = " + Str(respStatusCode))
System.DebugLog("Response Header:")
System.DebugLog(rest.ResponseHeader)
System.DebugLog("Response Body:")
System.DebugLog(sbResponseBody.GetAsString())
Return
End If
Dim jsonResponse As New Chilkat.JsonObject
success = jsonResponse.LoadSb(sbResponseBody)
// See the Online Tool for Generating JSON Parse Code
Dim i As Int32
Dim count_i As Int32
Dim kind As String
kind = jsonResponse.StringOf("kind")
i = 0
count_i = jsonResponse.SizeOfArray("items")
While i < count_i
jsonResponse.I = i
kind = jsonResponse.StringOf("items[i].kind")
Dim id As String
id = jsonResponse.StringOf("items[i].id")
Dim selfLink As String
selfLink = jsonResponse.StringOf("items[i].selfLink")
Dim name As String
name = jsonResponse.StringOf("items[i].name")
Dim bucket As String
bucket = jsonResponse.StringOf("items[i].bucket")
Dim generation As String
generation = jsonResponse.StringOf("items[i].generation")
Dim metageneration As String
metageneration = jsonResponse.StringOf("items[i].metageneration")
Dim contentType As String
contentType = jsonResponse.StringOf("items[i].contentType")
Dim timeCreated As String
timeCreated = jsonResponse.StringOf("items[i].timeCreated")
Dim updated As String
updated = jsonResponse.StringOf("items[i].updated")
Dim storageClass As String
storageClass = jsonResponse.StringOf("items[i].storageClass")
Dim timeStorageClassUpdated As String
timeStorageClassUpdated = jsonResponse.StringOf("items[i].timeStorageClassUpdated")
Dim size As String
size = jsonResponse.StringOf("items[i].size")
Dim md5Hash As String
md5Hash = jsonResponse.StringOf("items[i].md5Hash")
Dim mediaLink As String
mediaLink = jsonResponse.StringOf("items[i].mediaLink")
Dim crc32c As String
crc32c = jsonResponse.StringOf("items[i].crc32c")
Dim etag As String
etag = jsonResponse.StringOf("items[i].etag")
i = i + 1
Wend
{
"kind": "storage#objects",
"items": [
{
"kind": "storage#object",
"id": "chilkat-bucket/hedgehogs.jpg/1540253106638630",
"selfLink": "https://www.googleapis.com/storage/v1/b/chilkat-bucket/o/hedgehogs.jpg",
"name": "hedgehogs.jpg",
"bucket": "chilkat-bucket",
"generation": "1540253106638630",
"metageneration": "1",
"contentType": "image/jpeg",
"timeCreated": "2018-10-23T00:05:06.638Z",
"updated": "2018-10-23T00:05:06.638Z",
"storageClass": "MULTI_REGIONAL",
"timeStorageClassUpdated": "2018-10-23T00:05:06.638Z",
"size": "48573",
"md5Hash": "TE1U6fQlD6MOVGaQbwGinQ==",
"mediaLink": "https://www.googleapis.com/download/storage/v1/b/chilkat-bucket/o/hedgehogs.jpg?generation=1540253106638630&alt=media",
"crc32c": "1B2d6g==",
"etag": "CKaepPqhm94CEAE="
},
{
"kind": "storage#object",
"id": "chilkat-bucket/penguins.jpg/1540253106941673",
"selfLink": "https://www.googleapis.com/storage/v1/b/chilkat-bucket/o/penguins.jpg",
"name": "penguins.jpg",
"bucket": "chilkat-bucket",
"generation": "1540253106941673",
"metageneration": "1",
"contentType": "image/jpeg",
"timeCreated": "2018-10-23T00:05:06.941Z",
"updated": "2018-10-23T00:05:06.941Z",
"storageClass": "MULTI_REGIONAL",
"timeStorageClassUpdated": "2018-10-23T00:05:06.941Z",
"size": "777835",
"md5Hash": "nTd7EM53jEk4s8fixjoimg==",
"mediaLink": "https://www.googleapis.com/download/storage/v1/b/chilkat-bucket/o/penguins.jpg?generation=1540253106941673&alt=media",
"crc32c": "ixxYVw==",
"etag": "COndtvqhm94CEAE="
},
{
"kind": "storage#object",
"id": "chilkat-bucket/starfish.jpg/1540253106637454",
"selfLink": "https://www.googleapis.com/storage/v1/b/chilkat-bucket/o/starfish.jpg",
"name": "starfish.jpg",
"bucket": "chilkat-bucket",
"generation": "1540253106637454",
"metageneration": "1",
"contentType": "image/jpeg",
"timeCreated": "2018-10-23T00:05:06.636Z",
"updated": "2018-10-23T00:05:06.636Z",
"storageClass": "MULTI_REGIONAL",
"timeStorageClassUpdated": "2018-10-23T00:05:06.636Z",
"size": "6229",
"md5Hash": "LpxZ2/JmI2fcl9/dqF2gSA==",
"mediaLink": "https://www.googleapis.com/download/storage/v1/b/chilkat-bucket/o/starfish.jpg?generation=1540253106637454&alt=media",
"crc32c": "9RjgwQ==",
"etag": "CI6VpPqhm94CEAE="
}
]
}