Wiki
Download
Manual
Eggs
API
Tests
Bugs
show
edit
history
You can edit this page using
wiki syntax
for markup.
Article contents:
== Outdated egg! This is an egg for CHICKEN 4, the unsupported old release. You're almost certainly looking for [[/eggref/5/amazon-s3|the CHICKEN 5 version of this egg]], if it exists. If it does not exist, there may be equivalent functionality provided by another egg; have a look at the [[https://wiki.call-cc.org/chicken-projects/egg-index-5.html|egg index]]. Otherwise, please consider porting this egg to the current version of CHICKEN. == Amazon S3 [[toc:]] === Description A simple API to use the Amazon S3 service. === Requirements * [[base64]] * [[sha1]] * [[http-client]] * [[uri-common]] * [[intarweb]] * [[srfi-19]] * [[hmac]] * [[ssax]] * [[sxpath]] === List of user configurable parameters ==== {{access-key}} <parameter>(access-key [string])</parameter> This needs to be set before you can access S3. This is your AWS access key. ==== {{secret-key}} <parameter>(secret-key [string])</parameter> This needs to be set before you can access S3. This is your AWS secret key. ==== {{https}} <parameter>(https [boolean])</parameter> If set to {{#t}} Amazon S3 will be accessed via https. Defaults to {{#f}}. Deprecated in favor of {{make-base-uri}}. === {{make-base-uri}} A procedure of one argument which accepts a bucket name (either a string or {{#f}} if this is a request for managing buckets) and constructs the base URI (a [[uri-common]] object) for accessing the bucket. The default method checks for {{https}} and constructs {{<bucket-name>.s3.amazonaws.com}} if given a bucket, or {{s3.amazonaws.com}} if there is no bucket. Overriding this allows you to use this egg with an S3-compatible storage that's not Amazon's original one (like for example a local [[https://www.ceph.com/|Ceph]] instance). === List of Procedures All procedures return three values. The first will be the return value for the procedure. The second is the request-uri. The third is the response object. See http-client's call-with-input-request (Amazon S3 uses this and returns the same values). Errors are unspecified and will occur if you do anything that results in an error. Such as: not setting up your AWS access or secret keys correctly, trying to access something you don't have permissions to, trying to create a bucket that already exists, etc. This is subject to change. ==== {{list-buckets}} <procedure>(list-buckets)</procedure> Returns a list of your buckets. ==== {{bucket-exists?}} <procedure>(bucket-exists? bucket)</procedure> Returns {{#t}} when the specified bucket exists, {{#f}} otherwise. ==== {{create-bucket!}} <procedure>(create-bucket! bucket)</procedure> Creates a bucket. If the bucket already exists, you will most likely get an error. The result of this call is unspecified. ==== {{delete-bucket!}} <procedure>(delete-bucket! bucket)</procedure> Attempts to delete the specified bucket. If the bucket doesn't exist or can't be deleted, you will get an unspecified error. ==== {{list-objects}} <procedure>(list-objects bucket)</procedure> Returns a list of all the objects in the specified bucket. ==== {{put-object!}} <procedure>(put-object! bucket key object-thunk object-length object-type)</procedure> This is the basic/raw way of putting an object on S3. It is recommended to use either {{put-string!}} or {{put-sexp!}}, if you can. Takes a bucket, a key (string) for identifying the object, a thunk that returns the object, the length of the object, and the object type. If the key already specifies an object on S3, the object will be replaced. As an example, {{put-string!}} is implemented like this: {{(put-object! bucket key (lambda () string) (string-length string) "text/plain")}}. The return is unspecified. ==== {{put-string!}} <procedure>(put-string! bucket key string)</procedure> Simply takes a bucket, key (string) to identify the string, and the string to put on S3; and pushes the string to S3. If the key already specifies an string on S3, the string will be replaced. The return is unspecified. ==== {{put-sexp!}} <procedure>(put-sexp! bucket key sexp)</procedure> Simply takes a bucket, key (string) to identify the sexp, and a quoted s-expression to put on S3; and pushes the s-expression to S3. If the key already specifies a s-exp on S3, the s-exp will be replaced. The return is unspecified. ==== {{put-file!}} <procedure>(put-file! bucket key file-path)</procedure> Upload a file. ==== {{get-file}} <procedure>(get-file bucket key file-path)</procedure> Retrieve arbitrary item and write it to {{file-path}}. ==== {{get-object}} <procedure>(get-object bucket key)</procedure> Takes a bucket and an object key and returns the object identified by the key. Note that all procedures that call to S3 also return request response. ==== {{get-string}} <procedure>(get-string bucket key)</procedure> Takes a bucket and an object key and returns the string identified by the key. ==== {{get-sexp}} <procedure>(get-sexp bucket key)</procedure> Takes a bucket and an object key and returns the s-expression identified by the key. Note that a returned s-expression must be {{eval}}ed before it can be treated as code. ==== {{delete-object!}} <procedure>(delete-object! bucket key)</procedure> Takes a bucket and an object key and attempts to delete the object identified by the key. If the object can't be deleted, an unspecified error will occur. === List of macros ==== {{with-bucket}} <syntax>(with-bucket bucket ...)</syntax> All amazon-s3 operations in the body will use the specified bucket without requiring it to be explicitly set. WARNING! DEPRECATED This is broken and only works with calls that start with {{bucket}}. The next version of this lib will make this pattern obsolete. <enscript type="scheme"> (with-bucket "foo" (put-file! "foo-file" "~/foo") (get-file "foo-file" "~/foo2")) (with-bucket "foo" (+ 1 2 3)) ; this will not work! </enscript> === About ==== Author [[http://thintz.com|Thomas Hintz]] ==== Maintainers Seth Alves alves@hungry.com ==== Repository The source is maintained on [[https://github.com/sethalves/chicken-scheme-amazon-s3|github]]. ==== Version History ===== 0.9 * acl keyed parameter ===== 0.8 * Changed versioning system. * Added put-file!, get-file, and with-bucket. * Bug fix for put-string! and put-sexp! Thanks to Seth Alves. ===== 4 Initial release.
Description of your changes:
I would like to authenticate
Authentication
Username:
Password:
Spam control
What do you get when you add 3 to 2?