Today all companies moves their data to the cloud, you can use cloud for many purposes such is as data storage, remote machines, servers different types of network etc.
The common way today is use cloud as data storage, there are many options and different service providers for cloud data storage.
One of many providers and probably the most popular is Amazon and their Amazon S3 service (Amazon Simple Storage Service) which is storage for the internet.
Amazon S3 have simple web interface and we can use is to download or upload any amount of data, except web interface we can use this service as application programming interface (API) and intergrate this service in our own applications.
Using Amazon S3 in our applications is easy but it gives new dimension to our apps, integration can be done in many different ways, for the most popular programming languages today (Java, PHP, Paython, Ruby, .Net) it is straightforward because there are SDKs and libraries that enables us this service usage.
For other programming languses we can use Amazon S3 by making requests using REST API, this way also is not complicated and can be used in almost all programming languages.
But what if your company uses Coldfusion programming languages for app development, many of you did not heard about this programming language but in my company it is primarily used for development.
So one day I had task to integrate Amazon S3 in Coldfusion app, I tought it could be complicated because this programming language is not so popular and probably there is no any easiest way to do this except standard way of making web requests and using REST API.
The task was about copying some files from server to the Amazon S3, copying files on same server is very easy and there is FileCopy function for this purpose, usage this coldfusion function is simple, for example if we want copy some txt file from one location to another, in coldfusion this will be done in following way:
FileCopy(”C:/Folder1/example.txt”, ”C:/Folder2/example.txt”);
First parameter of the function is source path and second is destination path. This code will copy example.txt file from Folder1 to the Folder2 on the coldfusion server, this was very easy, but how to copy exmple.txt from Folder1 to the Amazon S3, how code should look like?
Answer is the same, we can use same function for copying files from coldfusion server to the Amazon S3 and vice versa, difference will be only in destination path, this is example:
FileCopy(”C:/Folder1/example.txt”, “s3://AccessKey+SecretKey@bucket/example.txt”);
As we can see, we can use same coldfusion function for copyiing files without difference if we are copying on server hard drive or on Amazon S3, this is possible because coldfusion have support for Amazon S3 service (available from ColdFusion 9.0.1).
In the exaple above we can see that difference is only in destination path, destination path contains some values that are specific only for copying to the Amazon S3:
- AccessKey – value is used for authentification on S3 service, need to be added in predifined position in destination path
- SecretKey – value is used for authentification on S3 service, need to be added in predifined position in destination path
- Bucket – value is used as path on amazon server, it can contains amazon bucket name and folders and subfolders to the end file destination
When copying files from Amazon S3 to the coldfusion server same logic is applicable, only source and destination address need to be configured.
In the example described above we can see that Amazon S3 integration with coldfusion applications is very easy and simple, in this way our applications can be better and clients happier.