Xbase++
Xbase++
S3 Delete File
See more Amazon S3 Examples
Demonstrates how to delete a remote file (object) on the Amazon S3 service.Chilkat Xbase++ Downloads
LOCAL nSuccess
LOCAL oHttp
LOCAL cBucketName
LOCAL cObjectName
nSuccess := 0
// This example assumes the Chilkat HTTP API to have been previously unlocked.
// See Global Unlock Sample for sample code.
oHttp := CreateObject("Chilkat.Http")
// Insert your access key here:
oHttp:AwsAccessKey := "AWS_ACCESS_KEY"
// Insert your secret key here:
oHttp:AwsSecretKey := "AWS_SECRET_KEY"
cBucketName := "chilkattest"
cObjectName := "starfish.jpg"
oHttp:KeepResponseBody := 1
nSuccess := oHttp:S3_DeleteObject(cBucketName, cObjectName)
IF (nSuccess != 1)
? oHttp:LastErrorText
oHttp:destroy()
RETURN
ENDIF
IF (oHttp:LastStatus != 204)
? "Status code = " + Str(oHttp:LastStatus)
? oHttp:LastResponseBody
? "Failed."
oHttp:destroy()
RETURN
ENDIF
// 204 is the success response status.
// When successful, the response body will be empty.
? "Status code = " + Str(oHttp:LastStatus)
? "Success. Object deleted."
oHttp:destroy()