Sample code for 30+ languages & platforms
PowerBuilder

S3 Delete File

See more Amazon S3 Examples

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

Chilkat PowerBuilder Downloads

PowerBuilder
integer li_rc
long li_Success
oleobject loo_Http
string ls_BucketName
string ls_ObjectName

li_Success = 0

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

loo_Http = create oleobject
li_rc = loo_Http.ConnectToNewObject("Chilkat.Http")
if li_rc < 0 then
    destroy loo_Http
    MessageBox("Error","Connecting to COM object failed")
    return
end if

//  Insert your access key here:
loo_Http.AwsAccessKey = "AWS_ACCESS_KEY"

//  Insert your secret key here:
loo_Http.AwsSecretKey = "AWS_SECRET_KEY"

ls_BucketName = "chilkattest"
ls_ObjectName = "starfish.jpg"

loo_Http.KeepResponseBody = 1
li_Success = loo_Http.S3_DeleteObject(ls_BucketName,ls_ObjectName)

if li_Success <> 1 then
    Write-Debug loo_Http.LastErrorText
    destroy loo_Http
    return
end if

if loo_Http.LastStatus <> 204 then
    Write-Debug "Status code = " + string(loo_Http.LastStatus)
    Write-Debug loo_Http.LastResponseBody
    Write-Debug "Failed."
    destroy loo_Http
    return
end if

//  204 is the success response status.
//  When successful, the response body will be empty.
Write-Debug "Status code = " + string(loo_Http.LastStatus)
Write-Debug "Success. Object deleted."


destroy loo_Http