Deletes a fie (also known as an object) from a Google Cloud Storage bucket. The name of the bucket is specified in the URL's path. This example deletes the "starfish.jpg" object from the "chilkat-test" bucket. A successful DELETE is indicated by a 204 response status code with an empty response body.
curl -X DELETE https://www.googleapis.com/storage/v1/b/chilkat-bucket/o/starfish.jpg?project=MY_CLOUD_STORAGE_PROJECT \
--header "Authorization: Bearer CLOUD_STORAGE_TOKEN"
var
rest: HCkRest;
success: Boolean;
bTls: Boolean;
port: Integer;
bAutoReconnect: Boolean;
sbResponseBody: HCkStringBuilder;
respStatusCode: Integer;
begin
rest := CkRest_Create();
// URL: https://www.googleapis.com/storage/v1/b/chilkat-bucket/o/starfish.jpg?project=MY_CLOUD_STORAGE_PROJECT
bTls := True;
port := 443;
bAutoReconnect := True;
success := CkRest_Connect(rest,'www.googleapis.com',port,bTls,bAutoReconnect);
if (success <> True) then
begin
Memo1.Lines.Add('ConnectFailReason: ' + IntToStr(CkRest_getConnectFailReason(rest)));
Memo1.Lines.Add(CkRest__lastErrorText(rest));
Exit;
end;
CkRest_AddHeader(rest,'Authorization','Bearer CLOUD_STORAGE_TOKEN');
sbResponseBody := CkStringBuilder_Create();
success := CkRest_FullRequestNoBodySb(rest,'DELETE','/storage/v1/b/chilkat-bucket/o/starfish.jpg?project=MY_CLOUD_STORAGE_PROJECT',sbResponseBody);
if (success <> True) then
begin
Memo1.Lines.Add(CkRest__lastErrorText(rest));
Exit;
end;
respStatusCode := CkRest_getResponseStatusCode(rest);
if (respStatusCode >= 400) then
begin
Memo1.Lines.Add('Response Status Code = ' + IntToStr(respStatusCode));
Memo1.Lines.Add('Response Header:');
Memo1.Lines.Add(CkRest__responseHeader(rest));
Memo1.Lines.Add('Response Body:');
Memo1.Lines.Add(CkStringBuilder__getAsString(sbResponseBody));
Exit;
end;
CkRest_Dispose(rest);
CkStringBuilder_Dispose(sbResponseBody);