Sample code for 30+ languages & platforms
AutoIt

Initiate Resumable Upload Session

See more Google Cloud Storage Examples

Initiate a Google Cloud Storage resumable upload session..

Chilkat AutoIt Downloads

AutoIt
Local $bSuccess = False

; This example assumes the Chilkat API to have been previously unlocked.
; See Global Unlock Sample for sample code.

$oHttp = ObjCreate("Chilkat.Http")

$oJsonToken = ObjCreate("Chilkat.JsonObject")
$bSuccess = $oJsonToken.LoadFile("qa_data/tokens/googleCloudStorage.json")
If ($bSuccess = False) Then
    ConsoleWrite($oJsonToken.LastErrorText & @CRLF)
    Exit
EndIf

$oJsonMetaData = ObjCreate("Chilkat.JsonObject")
$oJsonMetaData.UpdateString("contentType","image/jpeg")

; Adds the "Authorization: Bearer <access_token>" header..
$oHttp.AuthToken = $oJsonToken.StringOf("access_token")

$oHttp.SetUrlVar("bucket_name","chilkat-bucket-b")
$oHttp.SetUrlVar("object_name","penguins2.jpg")
Local $sUrl = "https://storage.googleapis.com/upload/storage/v1/b/{$bucket_name}/o?uploadType=resumable&name={$object_name}"
$oResp = ObjCreate("Chilkat.HttpResponse")
$bSuccess = $oHttp.HttpJson("POST",$sUrl,$oJsonMetaData,"application/json",$oResp)
If ($bSuccess = False) Then
    ConsoleWrite($oHttp.LastErrorText & @CRLF)
    Exit
EndIf

Local $iStatusCode = $oResp.StatusCode
ConsoleWrite("response status code = " & $iStatusCode & @CRLF)

Local $sessionUrl = ""

If ($iStatusCode <> 200) Then
    ConsoleWrite($oResp.BodyStr & @CRLF)
Else
    ; The session URL will be used to upload the file in chunks, in subsequent HTTP POSTs...
    $sessionUrl = $oResp.GetHeaderField("Location")
    ConsoleWrite("Session URL = " & $sessionUrl & @CRLF)
EndIf