(PureBasic) Wasabi Delete Bucket Objects
Demonstrates how to delete one or more objects in a bucket.Note: This example requires Chilkat v11.0.0 or greater.
IncludeFile "CkStringTable.pb"
IncludeFile "CkHttp.pb"
IncludeFile "CkHttpResponse.pb"
Procedure ChilkatExample()
success.i = 0
; 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
; 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"
st.i = CkStringTable::ckCreate()
If st.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
CkStringTable::ckAppend(st,objectName1)
CkStringTable::ckAppend(st,objectName2)
resp.i = CkHttpResponse::ckCreate()
If resp.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
success = CkHttp::ckS3_DeleteObjects(http,bucketName,st,resp)
If success = 0
Debug CkHttp::ckLastErrorText(http)
CkHttp::ckDispose(http)
CkStringTable::ckDispose(st)
CkHttpResponse::ckDispose(resp)
ProcedureReturn
EndIf
Debug "Response status code = " + Str(CkHttp::ckLastStatus(http))
; Display the XML response.
Debug CkHttpResponse::ckBodyStr(resp)
CkHttp::ckDispose(http)
CkStringTable::ckDispose(st)
CkHttpResponse::ckDispose(resp)
ProcedureReturn
EndProcedure
|