FTP Files from Google App Engine

I was wondering if an FTP / SFTP file from the Google App Engine servlet to a remote FTP / SFTP server is possible. Or maybe by creating a task on a TaskQueue ... Has anyone got this?

The GAE documentation says that "bytecode that tries to open a socket or write to a file will throw an exception at runtime"

Thank you for your time!

+4
source share
5 answers

Sockets are now available in the App Engine. You can use the ftp client library in App Engine, but there is one caveat. Only passive mode will work. In addition, in passive mode, sometimes the second connection will try to connect from a different IP address, which some servers ignore (for example, ftp.kernel.org). If this fails, try again, in the end you will get the same IP address and the transfer will work.

+2
source

The GAE documentation says that "bytecode that tries to open a socket or write to a file will throw an exception at runtime"

If I am not mistaken, this largely excludes the FTP file from GAE.

Here, a Google employee confirms that the port cannot be opened: http://groups.google.com/group/google-appengine/browse_thread/thread/21948f691660ca2/708036e7f2af595b?lnk=gst&q=ftp#708036e7f2af595b

But if you read it carefully, he says opening a port for listening is not allowed. You have to do it. I would like to hear from you the results of this experiment! :)

+1
source

Yes it is possible! We use it to send CSV files from Google Cloud Storage to a third-party provider that does not have any REST / SOAP API on its system. Here is an example in Python:

from ftplib import FTP import cloudstorage as gcs # Connect to vendor FTP site ftp = FTP('www.somevendor.com','vendorusername', 'vendormypassword') # Move into the specific folder where you want to place the file ftp.cwd('/path_to/target_folder') # Set the file name filename = 'my_csv_file.csv' # Get the file you want to FTP from Google Cloud Storage filepath = '/myapp.appspot.com/my_csv_file.csv' # Open the file to prep for transfer gcs_file = gcs.open(filepath,'r') # Initiate the file transfer ftp.storlines('STOR '+filename,gcs_file) # Close the ftp connection ftp.quit() # Close the file gcs_file.close() return 'You are done...MONEY!!!' 
+1
source

You cannot open sockets - of any type - in App Engine. All outgoing requests must be over HTTP.

0
source

Following this link

https://cloud.google.com/appengine/docs/python/sockets/

one of the points of limitations and limitations is

FTP is not supported

I am having problems with GAE using a different port for different packages, is this the only work for this to try several times until GAE uses the same port?

0
source

All Articles