A while back I wrote a vocab for using Amazon S3 (Simple Storage
Service) from Factor so I could archive tinyvid videos on S3. I've
tidied this up a bit and made it available. It's in the 's3' branch of
my git repository:

git://double.co.nz/git/factor.git

Hopefully it can be included in the main Factor distribution. Not all
functionality is available, only that which I needed for tinyvid. To
use it you need to set two dynamic variables:

  key-id - set to your Amazon S3 key
  secret-key - set to your Amazon S3 secret key

Once these are set you can use the vocab. A brief outline of the words:

buckets ( -- seq )
  Returns a sequences of buckets in your S3 area

create-bucket ( name -- )
  Create a bucket

delete-bucket ( name -- )
  Delete a bucket

keys ( bucket-name -- seq )
  Return a sequence of all keys in the given bucket

object-get ( bucket-name key -- headers data )
  Does an http-get to retrieve the object at the given key in the bucket

put-object ( data mime-type bucket-name key assoc -- )
  Stores the object under the key in the given bucket. The object has
the given mimetype. 'assoc' is contains key/values for any headers to
be associated with the object. 'data' is any Factor object that can be
used as the 'data' slot in <post-data>. If it's a <pathname> it stores
the contents of the file. If it's a stream, its' the contents of the
stream, etc. For example:

  "hello world" binary encode "text/plain" "testbucket" "hello.txt" H{
{ "x-amz-acl" "public-read" } } put-object
  "hello.txt" <pathname> "text/plain" "testbucket" "hello.txt" H{ {
"x-amz-acl" "public-read" } } put-object
  http://testbucket.s3.amazonaws.com/hello.txt http-get .nip .

I'll write some docs soon. Any suggestions on the interface
appreciated. Feel free to hack on the code, add new features, refactor
it, etc. I don' t mind. It's unlikely I'll be adding new features
unless I need them for tinyvid or other projects so if you want it,
add it.

Chris.
-- 
http://www.bluishcoder.co.nz

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to