Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Anyone here hosting their app on Amazon EC2


This question is answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 7 - Last Post: Jan 29, 2017 8:25 PM Last Post By: Lou Feliz
Lou Feliz

Posts: 114
Registered: 7/16/97
Anyone here hosting their app on Amazon EC2  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 26, 2017 9:03 AM
Hello,

I have a few projects hosted on AWS EC2 and my next step is to start consuming more AWS services. Anyone here have any luck using the Cloud connection component in Delphi to connect to and use Amazon S3 object storage? I am able to use the AWS load balancer with sticky sessions and the Amazon database service (Postgres) just fine. I have some file objects I need to manage (UPload/download in to folders of a bucket etc....) and S3 is the best choice, but getting a good working example is where I am stuck.

Anyway, I will keep experimenting and will share back an example if I am successful.

Cheers!

Edited by: Lou Feliz on Jan 29, 2017 8:25 PM
ioan ghip

Posts: 40
Registered: 3/16/00
Re: Anyone here hosting there app on Amazon EC2  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 26, 2017 9:27 AM   in response to: Lou Feliz in response to: Lou Feliz
I made a small, very basic S3 backup service, that zips files from different folders and then uploads them to a bucket on S3 storage.

You can check out the code here:
https://github.com/e1ioan/e1backup
Lou Feliz

Posts: 114
Registered: 7/16/97
Re: Anyone here hosting there app on Amazon EC2  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 26, 2017 10:54 AM   in response to: ioan ghip in response to: ioan ghip
Thank you for sharing this. I Will check it out right away.

- Lou
ioan ghip wrote:
I made a small, very basic S3 backup service, that zips files from different folders and then uploads them to a bucket on S3 storage.

You can check out the code here:
https://github.com/e1ioan/e1backup
Scott Gast

Posts: 82
Registered: 4/2/04
Re: Anyone here hosting there app on Amazon EC2  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 27, 2017 6:45 AM   in response to: ioan ghip in response to: ioan ghip
What Lou said! :)

ioan ghip wrote:
I made a small, very basic S3 backup service, that zips files from different folders and then uploads them to a bucket on S3 storage.

You can check out the code here:
https://github.com/e1ioan/e1backup
Scott Gast

Posts: 82
Registered: 4/2/04
Re: Anyone here hosting there app on Amazon EC2  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 26, 2017 9:40 AM   in response to: Lou Feliz in response to: Lou Feliz
Hey Lou,

I'm also using AWS EC2 and other AWS services. Within the next month or so, I plan on using AWS S3 storage... if (when) I get it figured out, I'll ping you. If you make some progress, let me know?

Thanks!
Scott
Texas, USA

Lou Feliz wrote:
Hello,

I have a few projects hosted on AWS EC2 and my next step is to start consuming more AWS services. Anyone here have any luck using the Cloud connection component in Delphi to connect to and use Amazon S3 object storage? I am able to use the AWS load balancer with sticky sessions and the Amazon database service (Postgres) just fine. I have some file objects I need to manage (UPload/download in to folders of a bucket etc....) and S3 is the best choice, but getting a good working example is where I am stuck.

Anyway, I will keep experimenting and will share back an example if I am successful.

Cheers!
Lou Feliz

Posts: 114
Registered: 7/16/97
Re: Anyone here hosting there app on Amazon EC2  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 27, 2017 4:20 PM   in response to: Scott Gast in response to: Scott Gast
Hi Scott,

After checking this example out I found a file code Central that has an example http://cc.embarcadero.com/Item/30546
It has an example project AmazonS3StoreStringDelphi

The example works once you set you credentials, and bucket name. You need to set the actual s3 storage endpoint and not use the default s3.amazonaws.com

- Lou

Scott Gast wrote:
Hey Lou,

I'm also using AWS EC2 and other AWS services. Within the next month or so, I plan on using AWS S3 storage... if (when) I get it figured out, I'll ping you. If you make some progress, let me know?

Thanks!
Scott
Texas, USA

Lou Feliz wrote:
Hello,

I have a few projects hosted on AWS EC2 and my next step is to start consuming more AWS services. Anyone here have any luck using the Cloud connection component in Delphi to connect to and use Amazon S3 object storage? I am able to use the AWS load balancer with sticky sessions and the Amazon database service (Postgres) just fine. I have some file objects I need to manage (UPload/download in to folders of a bucket etc....) and S3 is the best choice, but getting a good working example is where I am stuck.

Anyway, I will keep experimenting and will share back an example if I am successful.

Cheers!
Lou Feliz

Posts: 114
Registered: 7/16/97
Re: Anyone here hosting there app on Amazon EC2  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 28, 2017 9:04 AM   in response to: Lou Feliz in response to: Lou Feliz
After tinkering, Ioan's upload function works great with a binary file. The Coderage demo was good for a stringstream or short text file. Downloading a binary file is what I am trying to get working. I will work on it and post code snippet here or a demo project to Code Central.

- Lou

Lou Feliz wrote:
Hi Scott,

After checking this example out I found a file code Central that has an example http://cc.embarcadero.com/Item/30546
It has an example project AmazonS3StoreStringDelphi

The example works once you set you credentials, and bucket name. You need to set the actual s3 storage endpoint and not use the default s3.amazonaws.com

- Lou

Scott Gast wrote:
Hey Lou,

I'm also using AWS EC2 and other AWS services. Within the next month or so, I plan on using AWS S3 storage... if (when) I get it figured out, I'll ping you. If you make some progress, let me know?

Thanks!
Scott
Texas, USA

Lou Feliz wrote:
Hello,

I have a few projects hosted on AWS EC2 and my next step is to start consuming more AWS services. Anyone here have any luck using the Cloud connection component in Delphi to connect to and use Amazon S3 object storage? I am able to use the AWS load balancer with sticky sessions and the Amazon database service (Postgres) just fine. I have some file objects I need to manage (UPload/download in to folders of a bucket etc....) and S3 is the best choice, but getting a good working example is where I am stuck.

Anyway, I will keep experimenting and will share back an example if I am successful.

Cheers!
Lou Feliz

Posts: 114
Registered: 7/16/97
Re: Anyone here hosting there app on Amazon EC2  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jan 29, 2017 6:22 PM   in response to: Lou Feliz in response to: Lou Feliz
Success. If you look at Ioan's project, I just hacked a download function (below) and it does the job.

In my application I ensure the file being saved is a valid s3 file name etc.....

function TForm1.DownloadFile(AFileName, AFolder: string): Boolean;
var
FileContent: TBytes;
fReader: TBinaryReader;
fWriter : TBinaryWriter;
s3Service: TAmazonStorageService;
ResponseInfo: TCloudResponseInfo;
S3FileName: string;
Response: string;
Msg: string;
stream: TFileStream;
begin
stream := nil;
stream := TFileStream.Create('downloadedfile1111.xlsx', fmCreate);
CoInitialize(nil);

result := false;
{ AccessKeyID }
FAmazonKey := '<your key here>';
FAmazonSecret := '<secret here>';
FStorageEndpoint := 's3-us-west-2.amazonaws.com';// Need to specify the full s3 path
FAmazonBucket := '<bucket>';
AmazonConnectionInfo1.AccountName := FAmazonKey;
{ SecretAccessKeyID }
AmazonConnectionInfo1.AccountKey := FAmazonSecret;
AmazonConnectionInfo1.StorageEndpoint := FStorageEndpoint;
s3Service := TAmazonStorageService.Create(AmazonConnectionInfo1);
Response := s3Service.ListMultipartUploadsXML(FAmazonBucket, nil);
ResponseInfo := TCloudResponseInfo.Create;
try
if ContainsText(Response, '<error>') then
begin
Log(Response);
Result := false;
end
else
begin

//S3FileName := TNetEncoding.URL.Encode(ExtractFileName(AFolder+'/'+AFileName));
if AFolder = '' then
S3FileName := ExtractFileName(AFileName)
else
S3FileName := AFolder+'/'+ExtractFileName(AFileName);

Label1.Caption := S3FileName;
if s3Service.GetObject(FAmazonBucket, S3FileName, stream) then
//if s3Service.UploadObject(FAmazonBucket, DestinationFileName, FileContent, false, nil, nil, amzbaPublicRead, ResponseInfo) then
Log(S3FileName + ' downloaded sucessfully')
else
begin
Msg := 'Error trying to download' + S3FileName + 'from bucket ' + FAmazonBucket + ': ';
if ResponseInfo.StatusCode = 404 then
Msg := Msg + ' The bucket does not exists ';
Log(Msg + ResponseInfo.StatusMessage);
end;
end;
finally
stream.Free;
ResponseInfo.Free;
s3Service.Free;
CoUninitialize;
end;
end;

Lou Feliz wrote:
After tinkering, Ioan's upload function works great with a binary file. The Coderage demo was good for a stringstream or short text file. Downloading a binary file is what I am trying to get working. I will work on it and post code snippet here or a demo project to Code Central.

- Lou

Lou Feliz wrote:
Hi Scott,

After checking this example out I found a file code Central that has an example http://cc.embarcadero.com/Item/30546
It has an example project AmazonS3StoreStringDelphi

The example works once you set you credentials, and bucket name. You need to set the actual s3 storage endpoint and not use the default s3.amazonaws.com

- Lou

Scott Gast wrote:
Hey Lou,

I'm also using AWS EC2 and other AWS services. Within the next month or so, I plan on using AWS S3 storage... if (when) I get it figured out, I'll ping you. If you make some progress, let me know?

Thanks!
Scott
Texas, USA

Lou Feliz wrote:
Hello,

I have a few projects hosted on AWS EC2 and my next step is to start consuming more AWS services. Anyone here have any luck using the Cloud connection component in Delphi to connect to and use Amazon S3 object storage? I am able to use the AWS load balancer with sticky sessions and the Amazon database service (Postgres) just fine. I have some file objects I need to manage (UPload/download in to folders of a bucket etc....) and S3 is the best choice, but getting a good working example is where I am stuck.

Anyway, I will keep experimenting and will share back an example if I am successful.

Cheers!
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02