Initializing help system before first use

Usage examples

Topics covered in this chapter:

Downloading from an S3 object

This example demonstrates downloading the content of an S3 object with the key MyFile.txt into a local file MyDownloadedFile.txt.

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

model S3DownloadExample
uses "s3"

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

declarations
  LOCAL_FILE="MyDownloadedFile.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

! Download remote object to local file
s3getobject( 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

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

Listing S3 object keys

This example demonstrates listing the key names and last-modified dates of all object keys in our bucket that start with "MyPrefix/".

Note that the s3listobjects procedure fetches object keys in batches of up to 1000 - you will need to keep calling this procedure until the istruncated field is false to ensure you process all the keys.

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

model S3ListExample
uses "s3"

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

declarations
  PREFIX="MyPrefix/"
  mybucket: s3bucket
  objslistresult: s3objectlist
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

repeat
  ! Request objects list
  s3listobjects( mybucket, PREFIX, "", objslistresult )

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

  ! Process objects returned
  forall (o in objslistresult.objects) do
    writeln('Object key:',o.key,', last-modified:',o.lastmodified)
  end-do

  ! Repeat until we've fetched the last batch of object keys
until not objslistresult.istruncated
	
end-model

© 2001-2025 Fair Isaac Corporation. All rights reserved. This documentation is the property of Fair Isaac Corporation (“FICO”). Receipt or possession of this documentation does not convey rights to disclose, reproduce, make derivative works, use, or allow others to use it except solely for internal evaluation purposes to determine whether to purchase a license to the software described in this documentation, or as otherwise set forth in a written software license agreement between you and FICO (or a FICO affiliate). Use of this documentation and the software described in it must conform strictly to the foregoing permitted uses, and no other use is permitted.