Delphi Handbooks Collection


Delphi XE Handbook


Delphi 2010 Handbook


May 31, 2011

Delphi REST Clients Repository Opening With Amazon S3

Today, I'm officially opening my "Delphi REST Clients" SVN repository (hosted on code.marcocantu.com) with a rather complete class for working with Amazon S3, Simple Storage Service.

Today, I'm officially opening my "Delphi REST Clients" SVN repository (hosted on code.marcocantu.com) at http://code.marcocantu.com/p/delphirestclients/

The subversion command to get the entire repository (currently quite limited) is:

      svn co -r HEAD http://code.marcocantu.com/svn/marcocantu/delphirestclients
    

My intension is to use this repository for hosting all of the various REST client classes and demos Ive' written over the last few years. Contributions by other developers are welcome. 

Amazon S3

As a starting point, I'm finally making available the soruce code of my class for working with Amazon S3, Simple Storage Service. I had introduced this Amazon S3 class at the last CodeRage, and covered it in a past article of http://www.blaisepascal.eu/. Now I've written a new article, which will become available soon and coverign this extended version of the demo. I think this is a relevant example, as the only freely available Delphi code for Amazon S3 was a very old demo by Tim Anderson, at http://www.itwriting.com/blog/23-amazon-s3-delphi-sample.html. There is also some interesting ocde (different from mine) by Chilkat at http://www.example-code.com/delphi/s3_hmac_sha1.asp.

My project is based on a support class / component including a generic implementation of the secutiry algorithm required by S3 () and offering the following ready-to-use methods:

 

    // global operations
    function ListBuckets: TArray <TBucketInfo>;

    // buckest operations
    procedure CreateBucket (const bucketName: string);
    procedure DeleteBucket (const bucketName: string);
    function BucketContent (const bucketName: string): TArray <TObjectInfo>;

    // objects operations
    procedure UploadObject (const BucketName, Name, FileName, ContentType: string);
    procedure DownloadObject (const BucketName, Name: string; aStream: TStream);
    procedure DeleteObject (const BucketName, Name: string);

 

I might improve the code making actual calls indie threads, while now they use Indy directly and so they are blocking. This is not the complete intereface of S3, as it misses authorization requests and other settings, but it is certainly quite a good start. You can use it for listing folders, getting the contents of each, create and delete folders, upload and download files.

Note: You need to have an amazon.ini file in your documents folder with your access key and secret access key to use this project.

For more information refer to the article... or some future book of mine. Below is main form of the project, I plan showing this demo with a video ASAP (most showing how to use it, than how it works internally).

 

 





 

7 Comments

Delphi REST Clients Repository Opening With Amazon S3 

 Wow!!

Great work Marco.

This is just what we need.

I don't know if I'm good enough to contribute to the 
project, but if I am, I will.

I hope you present this at DelphiLive.

Thanks,

Keith
Comment by Keith on May 31, 23:47

Delphi REST Clients Repository Opening With Amazon S3 

Keith, thanks for the feedback. Use it, find any bug, 
try calling extra APIs not supported... anything helps 
the project.

As the Delphi Live I won't be there. I don't speak at 
conferences for which I have to pay my own flight and 
expenses (and also I'm not sure I'd be welcomed at this 
conference).

Come to the next year Delphi Developer Days in US and 
I'll have a session on REST clients <g>.
Comment by Marco Cantu [http://www.marcocantu.com] on June 1, 07:36

Delphi REST Clients Repository Opening With Amazon S3 

Marco,
A good endeavor from your side! I know you have some 
arguments against the SOAP and in favor of REST. Do you 
plan any examples of SOAP servers and clients?
Thank you!
Comment by IL [] on June 2, 21:23

Delphi REST Clients Repository Opening With Amazon S3 

The goal is to focus on REST clients. Most of the public 
services I use (for example Google ones) don't even have 
a SOAP interface. And Delphi support for SOAP is not 
always impeccable... mostly because there are variations 
on SOAP.
Comment by Marco Cantu [http://www.marcocantu.com] on June 2, 21:26

Delphi REST Clients Repository Opening With Amazon S3 

Good morning!   I am trying to get this to work using D7 and Indy 10 and 
I keep getting a TCP error 10053 when I try to put an object.  Oddly, the 
download works fine.  Same access key, etc.  Any thoughts?  Thank you! 
Comment by Malcolm on July 11, 13:08

Delphi REST Clients Repository Opening With Amazon S3 

Do you have this client for Delphi 2007?
Comment by Aleksey on July 22, 12:21

Delphi REST Clients Repository Opening With Amazon S3 

I have been able to rewrite your code for Delphi 2007
but i don't know how to Delete object. TIDHTTP doesn't
have Delete in D 2007. Can somebody help me?
Comment by Aleksey on July 25, 09:08


Post Your Comment

Click here for posting your feedback to this blog.

There are currently 0 pending (unapproved) messages.