Sending file from S3 to third party FTP server using CloudFront - ftp

I have some files that are stored on S3.
On users request, I want to transfer them to FTP server of a third party site.
Amazon S3 does not support FTP/SFTP.
Currently I am downloading the file from S3 to my local server using S3 APIs and then transferring it to third party FTP server.
S3 --API--> Local --FTP--> Third party FTP
Now, instead I want to transfer the files directly to third party FTP server directly from S3 without downloading it to my local server.
S3 ---CloudFront or Other Service---> Third Party FTP
How can I do it using cloudfront or any other services?
Any Help will be appreciated.
Thanks in advance.

S3 only has APIs to get data to it and from it. It also has an API function to copy data between two buckets, but that's about it.
If you require to transfer data from S3 to other places and want to save the download from S3 to your local machine I suggest you start a t1.micro instance and put a script on it to download the files to it (you won't pay the bandwidth because between S3 and EC2 instance on the same region you don't pay anything and its significantly faster) and then upload from that instance to the remote 3rd party FTP site.

Related

How to retrieve source code from Amazon Elastic Compute?

My application is hosted on Amazon Elastic Compute Cloud by the developer. I need to retrieve the source code for my web application. I am a new user so I need to know how can i download the source codes in my local host.
You need to log into the instance using SSH. If you're familiar with SSH then you can SCP from your local machine.
Of you're not familiar, you can use Systems Manager and transfer the data to S3 then download from there:
https://aws.amazon.com/premiumsupport/knowledge-center/systems-manager-ssh-vpc-resources/

Loading storage files from another server

I've put the database and files on separate servers (because I've set up 3 servers for our web application and use the load balancer for them) and I use SFTP for filestorage driver.
Because I've used the SFTP driver for Laravel file storage, the SSH connection to the destination server will increase and the SSH port will be block and the files cannot load from the storage server.
What should I do? is there any other solution to load files from another server?
I recommend using a cloud storage for this usecase, in which one can set the CORS settings. You could for instance use aws s3 for this or use digital ocean spaces which has a similiar api to s3.
You basically post your to that cloud server and save the url to your database.
Of course you need to set of the cors settings, to basically say that server x can access specific files on the cloud storage.

Transfer files from S3 to FTP

I'm trying to figure out if there is a way to write a ruby code that can copy file (200mb) from s3 bucket to ftp without having to pass data from s3 to server and than to ftp, is there a way to make the stream go directly to the ftp server?
You could use net-ssh to access the FTP server and then have it download from S3. Hope that helps!

Uploading to S3 from within an EC2 VPC

If we're uploading files to S3 from within our AWS VPC, do we have to do anything special other than initiate an upload through the S3 API on the standard URL?
We're planning on using the aws-s3 Ruby gem to do the transfer and just trying to figure out if there are changes we need to make in order to ensure that the data transfer is free.
Thanks in advance!
Data transfer in the form of uploads is always free whether you are in or out of the AWS network. You do however have to pay for LIST/PUT/COPY/POST requests both in and out of network.
You get free transfer OUT of S3 when it is sent to AWS instance, and this is done in the same manner you would do it if you were GETing data outside AWS. They do the resolution to the S3 url and route it internally, no different syntax needed. Again you still pay for the GET request but this time you save money on the transfer bandwidth.
Please do note however if you are connecting to S3 outside the AWS region you are in (IE connecting to S3 Northern VA -> AWS West) you will have to pay for outbound S3 traffic.

AWS: To redirect or to proxy files

Let me explain dilemma.
I use 3 services from Amazon: EC2, S3 and CloudFront.
EC2 receives an file as upload, stores it in the S3 bucket. Then CloudFront mirrors the S3 bucket. The only limit is to have user friendly URLs.
Which approach to deliver those files is better?
Client > CloudFront > EC2 > S3
Client does a HTTP request to CloudFront URL
Cloudfront forwards the request to EC2
EC2 translates user friendly URL to raw file URL
EC2 reads the file from S3
Client > EC2 ... redirect ... CloudFront > S3
Client does a HTTP request to EC2
EC2 translates user friendly URL to raw file URL
EC2 redirects to CloudFront, witch mirrors the S3
There are two dimensions for this: the speed and the cost.
I see facebook using the second approach when serving profile images
http://graph.facebook.com/platform/picture
You certainly don't want to force the file transfer between S3 and your client to go through your EC2 instance. That will add load to the EC2 instance, increase bandwidth usage, and undoubtedly slow the response to the user.
Your EC2 instance gives you the greatest control over URL format, so you'll want the client to make the initial request to it (to have a "user-friendly" URL). The EC2 instance can just send the client a redirect to the CloudFront or S3 URL that actually has the content, and the client will pull it directly from there without the further involvement of EC2.
I wouldn't bother with CloudFront unless you have an enormous number of requests, or network latency has to be as low as possible.
I personally would just give the files a nice name and a proper content type metatag in S3 when first doing the file upload and, as such, remove your EC2 instances from the download path altogether. You would just serve the clean-url to you client in your HTML content and that clean URL will point directly to you resources in Cloudfront/S3, which has the proper metatags to serve up the desired content-type header.

Resources