(Lianja) Backblaze S3 Upload Binary
Demonstrates how to upload the in-memory binary data to an Backblaze bucket.
llSuccess = .F.
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
loHttp = createobject("CkHttp")
// keyID = Access Key ID or Access Key
loHttp.AwsAccessKey = "access-key"
// applicationKey = Secret Access Key or Secret Key
loHttp.AwsSecretKey = "secret-key"
// Region is the 2nd part of your S3 Endpoint
loHttp.AwsEndpoint = "s3.us-west-002.backblazeb2.com"
lcBucketName = "chilkat-test-123"
lcObjectName = "starfish.jpg"
// The Content-Type has the form type/subtype, such as application/pdf, application/json, image/jpeg, etc.
// See Explaining Content-Types
lcContentType = "image/jpeg"
loHttp.KeepResponseBody = .T.
loJpgData = createobject("CkBinData")
llSuccess = loJpgData.LoadFile("qa_data/jpg/starfish.jpg")
llSuccess = loHttp.S3_UploadBd(loJpgData,lcContentType,lcBucketName,lcObjectName)
if (llSuccess <> .T.) then
? loHttp.LastErrorText
loXml = createobject("CkXml")
loXml.LoadXml(loHttp.LastResponseBody)
? loXml.GetXml()
else
? "JPG uploaded."
endif
release loHttp
release loJpgData
release loXml
|