Sample code for 30+ languages & platforms
AutoIt

S3 Delete File

See more Amazon S3 Examples

Demonstrates how to delete a remote file (object) on the Amazon S3 service.

Chilkat AutoIt Downloads

AutoIt
Local $bSuccess = False

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

$oHttp = ObjCreate("Chilkat.Http")

; Insert your access key here
$oHttp.AwsAccessKey = "AWS_ACCESS_KEY"

; Insert your secret key here
$oHttp.AwsSecretKey = "AWS_SECRET_KEY"

Local $sBucketName = "chilkattest"
Local $sObjectName = "starfish.jpg"

$oHttp.KeepResponseBody = True
$bSuccess = $oHttp.S3_DeleteObject($sBucketName,$sObjectName)

If ($bSuccess <> True) Then
    ConsoleWrite($oHttp.LastErrorText & @CRLF)
    Exit
EndIf

If ($oHttp.LastStatus <> 204) Then
    ConsoleWrite("Status code = " & $oHttp.LastStatus & @CRLF)
    ConsoleWrite($oHttp.LastResponseBody & @CRLF)
    ConsoleWrite("Failed." & @CRLF)
    Exit
EndIf

; 204 is the success response status.
; When successful, the response body will be empty.
ConsoleWrite("Status code = " & $oHttp.LastStatus & @CRLF)
ConsoleWrite("Success. Object deleted." & @CRLF)