PureBasic
PureBasic
OSS Delete Bucket Objects (Alibaba Cloud)
See more Alibaba Cloud OSS Examples
Demonstrates how to delete objects in a bucket.The Chilkat S3 functions in the HTTP class are compatible with Alibaba Cloud's OSS service.
Chilkat PureBasic Downloads
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 AccessKey ID here:
CkHttp::setCkAwsAccessKey(http, "access-key")
; Insert your AccessKey Secret here:
CkHttp::setCkAwsSecretKey(http, "secret-key")
; To delete objects from a bucket located in a different region, use the domain for that region, such as "oss-cn-hangzhou.aliyuncs.com "
; See Alibaba Object Storage Service Regions and Endpoints
CkHttp::setCkAwsEndpoint(http, "oss-us-east-1.aliyuncs.com")
bucketName.s = "chilkat"
objectName1.s = "seahorse.jpg"
objectName2.s = "orchard.json"
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