(Visual FoxPro) Backblaze S3 Upload Binary
Demonstrates how to upload the in-memory binary data to an Backblaze bucket.
LOCAL lnSuccess
LOCAL loHttp
LOCAL lcBucketName
LOCAL lcObjectName
LOCAL lcContentType
LOCAL loJpgData
LOCAL loXml
lnSuccess = 0
* This example assumes the Chilkat API to have been previously unlocked.
* See Global Unlock Sample for sample code.
loHttp = CreateObject('Chilkat.Http')
* 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 = 1
loJpgData = CreateObject('Chilkat.BinData')
lnSuccess = loJpgData.LoadFile("qa_data/jpg/starfish.jpg")
lnSuccess = loHttp.S3_UploadBd(loJpgData,lcContentType,lcBucketName,lcObjectName)
IF (lnSuccess <> 1) THEN
? loHttp.LastErrorText
loXml = CreateObject('Chilkat.Xml')
loXml.LoadXml(loHttp.LastResponseBody)
? loXml.GetXml()
ELSE
? "JPG uploaded."
ENDIF
RELEASE loHttp
RELEASE loJpgData
RELEASE loXml
|