Gauche-net-amazon is a project mainly written in Scheme, based on the BSD-3-Clause license.
Gauche library to use Amazon web services.
This module provides convenient access methods to Amazon Web Services. Currently only a part of S3 interface is implemented.
Defines a common condition types and utilities. This module is supposed to be inherited by other sevice-specific modules (e.g. net.amazon.s3) so the user programs usually do not need to use this module directly.
Condition Type:
Condition Type:
Condition Type:
Condition Type:
Condition Type:
Parameter: aws-access-key-id Parameter: aws-secret-access-key
These parameters hold the keys required for the authentication of APIs. The user progam has to set these parameters before using APIs. See aws-read-config below for a convenient way.
Function: aws-read-config :optional (config-file #f)
Read and parse the file CONFIG-FILE. The config file must consists
of a series of S-expression (
If CONFIG-FILE is #f, a file ".awsconfig" in the process owner's home directory is read.
If the CONFIG-FILE does not exist, an empty list is returned.
If
Function: aws-keys-ready?
Returns #t iff the two API key parameters are set.
Provides access methods to the Amazon S3.
Some APIs come with two or more different "flavors". For example,
to obtain a list of buckets, we have s3-bucket-list' and
s3-bucket-list/raw'. The `/raw' version always returns two
values: the Amazon's response in SXML, and the list of headers
in the form that rfc822-header-ref can be used. Basically, it provides
all the information you need.
However, it is cumbersome to handle SXML every API call. So the
API with no '/' suffix returns a reasonable Scheme-y data structure.
In the case of `s3-bucket-list', it is a list of
(
When Amazon responds with a status code other than 200, most APIs
raises
Function: s3-bucket-list
Returns ((<bucket-name> <bucket-creation-date>) ...) for all
the buckets owned by the authenticated user. <bucket-creation-date>
is a <date> object.
Function: s3-bucket-list/raw
Raw version of s3-bucket-list.
Function: s3-bucket-availability bucket
BUCKET is a string of bucket name. This function returns either
a symbol used, available or taken.
Function: s3-bucket-create! bucket :key (location #f)
Creates a new bucket named BUCKET. A keyword argument LOCATION
can specify LocationConstraint argument. Returns no values
on success.
Function: s3-bucket-create/raw! bucket :key (location #f)
Raw version of s3-bucket-create!
Function: s3-bucket-delete! bucket
Deletes the named bucket. Returns no values on success.
Function: s3-bucket-delete/raw! bucket
Raw version of s3-bucket-delete!.
Function: s3-bucket-location bucket
Returns a symbol that shows where the bucket resides. Currently
the return value can be either one of the symbols EU, us-west-1 or
us-classic.
Function: s3-bucket-location/raw bucket
Raw version of s3-bucket-location.
Function: s3-bucket-acl/raw bucket
Returns the access control list of BUCKET in SXML. For this API,
we haven't decided what representation is appropriate for
convenience API, so currently we have only the raw version.
Function: s3-object-list bucket :key (prefix #f) (marker #f) (max-keys #f) (delimiter #f)
Returns a list of information of objects in the named bucket.
Meanings of the keyword arguments are as specified in Amazon
S3 REST API.
Each information of object is represented by a record type s3obj:
(define-record-type s3obj #t #t
key ;string
last-modified ;#<date>
etag ;string
size ;integer
owner-id ;string
owner-display-name ;string
storage-class ;string
)
Function: s3-object-list/key bucket :key (prefix #f) (marker #f) (max-keys #f) (delimiter #f)
This version just returns a list of the 'key' value (that is, names)
of the objects in the bucket.
Function: s3-object-list/raw bucket :key (prefix #f) (marker #f) (max-keys #f) (delimiter #f)
Raw version of s3-object-list.
Function: s3-object-put! bucket key data :key (cache-control #f) (content-disposition #f) (content-encoding #f) (content-length #f) (content-md5 #f) (content-type #f) (expires #f) (acl #f) (meta #f)
Put a object to a bucket with the name KEY in BUCKET. The type of
data must be a string or sxml. If you want to put binary data or
so, you should manually encode the data and you should set the
CONTENT-TYPE keyword correctly by yourself. The keywords of
CACHE-CONTROL, CONTENT-DISPOSITION, CONTENT-ENCODING,
CONTENT-LENGTH and CONTENT-TYPE are used under RFC2616
definition. CONTENT-MD5 is used for a message integrity check to
verify that the data is the same data that was originally
sent. The detail is defined in RFC1864. EXPIRES keyword is the
Number of milliseconds before expiration of the data on the
server. ACL keyword is used to set the object's acl. The acl value
should be one of followings: 'private, 'public-read,
'public-read-write , 'bucket-owner-read , 'authenticated-read or
'bucket-owner-full-control, and the default is 'private. The META
keyword is used to indicate user meta data that would be stored
with the object and returned when you retrieve the object. If you
indicate meta as '(("LEBEL" 2)), s3-object-put! add
"x-amz-meta-LEVEL: 2" to the header and send it to the server.
Returns ETag (entity tag) value that is set by Amazon S3 server.
Function: s3-object-put! bucket key data :key (cache-control #f) (content-disposition #f) (content-encoding #f) (content-length #f) (content-md5 #f) (content-type #f) (expires #f) (acl #f) (meta #f)
Raw version of s3-object-put!.
Function: s3-object-get bucket key :key (range #f) (if-modified-since #f) (if-unmodified-since #f) (if-match #f) (if-none-match #f)
Returns the content of the object. the RANGE keyword is used for
Downloads the specified range of an object. IF-MODIFIED-SINCE and
IF-UNMODIFIED-SINCE keyword is used if the object's timestamp is
bigger or lower, the server does not return the content for
response data retrenchment. You should indicate IF-MODIFIED-SINCE
or IF-UNMODIFIED-SINCE should be a string like "Sat, 29 Oct 1994
19:43:31 GMT".
IF-MATCH and IF-NONE-MATCH keywords are similar to
if-modified-since and if-unmodified-since keywords, but they
accept object's ETag(entity tag). If the object's ETag on the
server matches (or does not match) to the indicated one, the
server does not return (or returns) the content.
Function: s3-object-get/raw bucket key :key (range #f) (if-modified-since #f) (if-unmodified-since #f) (if-match #f) (if-none-match #f)
Raw version of s3-object-get.
Function: s3-object-head bucket key :key (range #f) (if-modified-since #f) (if-unmodified-since #f) (if-match #f) (if-none-match #f)
Almost identical to s3-object-get but this function return header
information (meta information) instead of the object content.
Function: s3-object-head/raw bucket :key (range #f) (if-modified-since #f) (if-unmodified-since #f) (if-match #f) (if-none-match #f)
Raw version of s3-object-head
Function: s3-object-copy! bucket src-bucket+key dst-key :key (acl #f) (metadata-directive #f) (copy-source-if-match #f) (copy-source-if-none-match #f) (copy-source-if-unmodified-since #f) (copy-source-if-modified-since #f)
Copies an object. src-bucket+key is a string like
"/srcbucket/hello.txt" (source-bucket-name + "/" + object-name)
and dst-key is a string like "hello.txt".
The keyword arguments ACL, COPY-SOURCE-IF-MATCH,
COPY-SOURCE-IF-NONE-MATCH, COPY-SOURCE-IF-UNMODIFIED-SINCE or
COPY-SOURCE-IF-MODIFIED-SINCE are same as
s3-object-put!. METADATA-DIRECTIVE is to specify whether the
metadata is copied from the source object or replaced with
metadata provided in the request. If copied, the metadata, except
for the version ID, remains unchanged. Otherwise, all original
metadata is replaced by the metadata you specify. valid values
for METADATA-DIRECTIVE is 'COPY or 'REPLACE.
If copy succeeded, s3-object-copy! returns string that represent
ETag of the copied object and if failed, it returns #f.
Function: s3-object-copy/raw! bucket src-bucket+key dst-key :key (acl #f) (metadata-directive #f) (copy-source-if-match #f) (copy-source-if-none-match #f) (copy-source-if-unmodified-since #f) (copy-source-if-modified-since #f)
Raw version of s3-object-copy!.
Function: s3-object-delete! bucket key :key (mfa #f)
Deletes a object. MFA keyword is required to permanently delete a
versioned object if versioning is configured with MFA Delete
enabled. MFA is the concatenation of the authentication device's
serial number, a space, and the value displayed on your
authentication device.
Function: s3-object-delete/raw! bucket key :key (mfa #f)
Raw version of s3-object-delete!.