Demonstrates how to delete a file from an S3 bucket. This example deletes the file /chilkat.ocean/starfishCopy.jpg. A response status code equal to 204 is returned for success (with an empty response body).
curl -X DELETE https://chilkat.ocean.s3.us-west-2.amazonaws.com/starfishCopy.jpg
Dim rest As New Chilkat.Rest
Dim success As Boolean
Dim authAws As New Chilkat.AuthAws
authAws.AccessKey = "AWS_ACCESS_KEY"
authAws.SecretKey = "AWS_SECRET_KEY"
authAws.Region = "us-west-2"
authAws.ServiceName = "s3"
success = rest.SetAuthAws(authAws)
// URL: https://chilkat.ocean.s3.us-west-2.amazonaws.com/starfishCopy.jpg
Dim bTls As Boolean
bTls = True
Dim port As Int32
port = 443
Dim bAutoReconnect As Boolean
bAutoReconnect = True
success = rest.Connect("chilkat.ocean.s3.us-west-2.amazonaws.com",port,bTls,bAutoReconnect)
If (success <> True) Then
System.DebugLog("ConnectFailReason: " + Str(rest.ConnectFailReason))
System.DebugLog(rest.LastErrorText)
Return
End If
Dim sbResponseBody As New Chilkat.StringBuilder
success = rest.FullRequestNoBodySb("DELETE","/starfishCopy.jpg",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