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.
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).