Skip to Navigation

2.6 Amazon S3 Functions

You may connect your CloudDot account to your Amazon S3 account to read and write data from CloudDot scripts. For example, you could write a CloudDot script that summarizes soil moisture data you’ve collected, writes a report, and uploads that report to Amazon S3. From there, you can use your Amazon account to download it or make the report available publicly available on the web.

Getting Started: Copy your Access Keys

You’ll need to signup for Amazon S3 to get started. Once you’ve created your account, visit your Account page and click on Security Credentials. Find the area that looks like this:

In the picture above, there are two keys because we generated a key specifically for CloudDot. This is useful if you later decide to stop using S3 with CloudDot, you can delete that key. Whatever key you decide to use, copy and paste the Access Key ID and Secret Access Key into these fields on your CloudDot Account page:

Using the s3Put() and s3Get() functions

Once you’ve copied your S3 Access Keys to your CloudDot Account page, you can call s3Put() and s3Get() from a CloudDot script. Here are two quick examples:

  
s3Put("test-from-clouddot", "This is a test message from CloudDot.")
  
  
print s3Get("test-from-clouddot")
This is a test message from CloudDot.
  

The format of s3Put() is

  
s3Put(filename, data)
  

The filename can include subdirectories; just specify a path like “dir1/file1.txt”. The directory “dir1” doesn’t have to exist before calling s3Put(). We’ve tested s3Put() primarily with text, but binary data will work, too.

The format of s3Get() is

  
data = s3Get(filename)
  

it returns the data from an existing file on S3, such as one created with s3Put().

S3 buckets

s3Put() and s3Get() accept an option to specify which bucket to use for your data.

  
s3Put("foo/bar", "This is a test message from CloudDot.", bucket="my-unique-bucket-name")
  

An S3 bucket is the top-level container where Amazon stores your data. If you don’t specify a bucket, s3Put() and s3Get() will use the bucket “username-clouddot”. If that bucket doesn’t exist, CloudDot will create it for you.

When choosing a bucket, remember that buckets must be globally unique across all Amazon S3 users.

Comments

No comments yet. Speak up. We're listening.