Initializing help system before first use

Uploading to an S3 object

This example demonstrates uploading the content of the file "MyLocalFile.txt" to the S3 bucket with the object key "MyFile.txt".

You will need to fill in the model parameters with your own Amazon S3 access credentials.

model S3UploadExample
uses "s3"

parameters
  S3_BUCKET_URL = ""
  S3_REGION = ""
  S3_ACCESS_KEY_ID = ""
  S3_SECRET_KEY = ""
end-parameters

declarations
  LOCAL_FILE="MyLocalFile.txt"
  OBJECT_KEY="MyFile.txt"
  mybucket: s3bucket
end-declarations

! Configure 'mybucket' with our S3 access credentials
mybucket.url := S3_BUCKET_URL
mybucket.region := S3_REGION
mybucket.accesskeyid := S3_ACCESS_KEY_ID
mybucket.secretkey := S3_SECRET_KEY

! Upload local file to remote object
s3putobject( mybucket, OBJECT_KEY, LOCAL_FILE )

! Check for errors
if s3status(mybucket)<>S3_OK then
  writeln("Error returned by S3 service: ", s3getlasterror(mybucket))
  exit(1)
end-if
	
end-model