Resources



Sample Code and Libraries

Amazon S3 Library for REST in Python

Click for a printer friendly version of this document Printer Friendly Save to del.icio.us
 

A library in Python for working with the Amazon S3 REST interface.

Submitted By: EricW@AWS  
AWS Products Used: Amazon S3
Language(s): Python
License: New BSD

About This Sample

  • A library in Python for working with the Amazon S3 REST interface.
  • Part of a collection of interface libraries, each in a different language.
  • See the README file in the download for more information about the sample.

What's New?

  • 2007-11-05: Updates to support EU
  • 2007-05-18: Updates to support signed HTTP requests to virtual hosted buckets.
  • 2006-10-02: Updates for server access logging.
  • 2006-07-06: Fixed bug where modifications to the default headers argument in make_request would be sticky and would cause errors in subsequent calls.
  • 2006-06-28: Fixed query string authentication tests.

Prerequisites

Running the Sample

  • See the README file in the attached download for information on running the sample.

Discussion

The 5 most recent discussion messages. View full discussion.

A. Nelson
RealName(TM)
Posts: 12
Registered: 7/2/08
Re: Amazon S3 Library for REST in Python
Posted: Aug 17, 2009 8:41 AM PDT   in response to: uuorld
 
  Click to reply to this thread Reply

The S3 library needs to be updated (And ideally moved to a better code repository like github.com):

Anyway, here is the current warning from Python 2.6:

This deprecation warning comes up in Python 2.6.2:

S3.py:16: DeprecationWarning: the sha module is deprecated; use the hashlib module instead
import sha

Just change
{{{
#!python

import sha
}}}
to

{{{
#!python

import hashlib
}}}

and then use hashlib.sha1()

Paul M.
Posts: 2
Registered: 10/8/09
Re: Amazon S3 Library for REST in Python ++ ACL policy parsing and creation
Posted: Oct 8, 2009 12:28 PM PDT   in response to: A. Nelson
 
  Click to reply to this thread Reply

I updated the s3.py file to account for the changes in python 2.6.  I also noticed that there was no object parsing support for ACL lists nor was there any way to create an ACL using an object approach.

I added a few additional classes and xml.sax handlers to parse the ACL lists.  There are also some classes for creating ACL policies from scratch.

I also embedded the unit tests in the file for compactness but, of course, they don't need to be there for production use.

Download the file here:

https://plaidcloud.s3.amazonaws.com/public/s3/s3.py.zip


A. Nelson
RealName(TM)
Posts: 12
Registered: 7/2/08
Re: Amazon S3 Library for REST in Python ++ ACL policy parsing and creation
Posted: Oct 8, 2009 12:40 PM PDT   in response to: Paul M.
 
  Click to reply to this thread Reply

Awesome Paul.

I'm considering this page to basically be dead - the AWS CMS is kind of ... not so great.

I moved the file where everybody can get at it, modify it, make tickets, etc....

http://github.com/AdamN/python-s3

A. Nelson
RealName(TM)
Posts: 12
Registered: 7/2/08
Re: Amazon S3 Library for REST in Python ++ ACL policy parsing and creation
Posted: Oct 19, 2009 1:16 PM PDT   in response to: Paul M.
 
  Click to reply to this thread Reply

Paul,

Can you clarify the addition of the copyright?

# (c) 2009 Tartan Solutions, Inc

This won't be usable on most libraries I'd like this integrated into if you're claiming copyright. It's fine, I just need to know so those changes aren't propagated to the GPL libraries that use s3.py.

Cheers,
Adam

A. Nelson
RealName(TM)
Posts: 12
Registered: 7/2/08
Re: Amazon S3 Library for REST in Python ++ ACL policy parsing and creation
Posted: Oct 28, 2009 8:51 AM PDT   in response to: A. Nelson
 
  Click to reply to this thread Reply

After careful consideration, I recommend all users use boto instead for a python s3 library as this library is no longer actively maintained:

http://boto.s3.amazonaws.com/index.html
http://code.google.com/p/boto/

It's not immediately obvious to a new Python user what to do when starting with S3 and Amazon Web Services, but boto is far and away the superior library.


Reviews
Create Review Write a Review
Be the first to review this.
Welcome, Guest Help
Login Login