(PureBasic) Wasabi Delete Bucket Objects
Demonstrates how to delete one or more objects in a bucket.
IncludeFile "CkHttpResponse.pb"
IncludeFile "CkHttp.pb"
IncludeFile "CkStringArray.pb"
Procedure ChilkatExample()
; This example requires the Chilkat API to have been previously unlocked.
; See Global Unlock Sample for sample code.
http.i = CkHttp::ckCreate()
If http.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
success.i
; Insert your access key here:
CkHttp::setCkAwsAccessKey(http, "access-key")
; Insert your secret key here:
CkHttp::setCkAwsSecretKey(http, "secret-key")
; Use the endpoint matching the bucket's region.
CkHttp::setCkAwsEndpoint(http, "s3.us-west-1.wasabisys.com")
bucketName.s = "chilkattest"
objectName1.s = "seahorse.jpg"
objectName2.s = "seahorse2.jpg"
sa.i = CkStringArray::ckCreate()
If sa.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
CkStringArray::ckAppend(sa,objectName1)
CkStringArray::ckAppend(sa,objectName2)
resp.i = CkHttp::ckS3_DeleteMultipleObjects(http,bucketName,sa)
If CkHttp::ckLastMethodSuccess(http) = 0
Debug CkHttp::ckLastErrorText(http)
CkHttp::ckDispose(http)
CkStringArray::ckDispose(sa)
ProcedureReturn
EndIf
Debug "Response status code = " + Str(CkHttp::ckLastStatus(http))
; Display the XML response.
Debug CkHttpResponse::ckBodyStr(resp)
CkHttpResponse::ckDispose(resp)
CkHttp::ckDispose(http)
CkStringArray::ckDispose(sa)
ProcedureReturn
EndProcedure
|