(Go) Demonstrate S3_DownloadBytes
Demonstrates how to download a file into memory from the Amazon S3 service.
// This example assumes the Chilkat HTTP API to have been previously unlocked.
// See Global Unlock Sample for sample code.
http := chilkat.NewHttp()
http.SetAwsAccessKey("AWS_ACCESS_KEY")
http.SetAwsSecretKey("AWS_SECRET_KEY")
bucketName := "chilkat.qa"
objectName := "images/sea_creatures/starfish.jpg"
localFilePath := "qa_output/starfish.jpg"
jpgBytes = http.S3_DownloadBytes(bucketName,objectName)
if http.LastMethodSuccess() != true {
fmt.Println(http.LastErrorText())
http.DisposeHttp()
return
}
fmt.Println("Download successful.")
fac := chilkat.NewFileAccess()
success := fac.WriteEntireFile(localFilePath,jpgBytes)
fmt.Println("File saved success = ", success)
http.DisposeHttp()
fac.DisposeFileAccess()
|