3

In Google App Engine is there any way to get a file via FTP or have a file FTPed to the application? I want to be able to send data to a vendor that only supports FTP.

Any suggestion? I appreciate any help and/or ideas that anyone has

Thanks Abhijeet

Sinha
  • 773
  • 2
  • 16
  • 34
  • Nope, the appengine platform is as of now HTTP only. (Sockets are on the way) – fredrik Oct 06 '12 at 08:50
  • I had the same problem (no FTP), when we designed the application a few years ago and before we start using app engine. Our solution: the vendor logs in to download the data after being informed by e-mail. – voscausa Oct 06 '12 at 12:14

4 Answers4

2

This limitation used to drive me nuts, but as of April 9 this year (SDK 1.7.7) this isn't a problem any longer. Outbound sockets (e.g. FTP) are generally available to all billing-enabled apps.

Overview (Python): https://developers.google.com/appengine/docs/python/sockets/

mblomdahl
  • 147
  • 1
  • 8
  • 1
    To clarify further, this means you can use Python libraries like FTP Lib to send and receive files via FTP. Been there, done that. Works great. – Jude Osborn Aug 25 '13 at 23:00
  • @JudeOsborn can you show me how you managed to store a file on an ftp server? i always end up in a 'connection timed out'... – aschmid00 May 01 '14 at 15:11
  • 1
    @aschmid00: Not sure if this is the prettiest of solutions, but I used to have the same problem. In the [snippet](http://pastebin.com/2kfK1dbv) I referred you to in my previous comment, on line 22, I keep sending a `NOOP` command to the remote server every 60 seconds or so. I often need to maintain the connection for up to 10 minutes (slow-ass FTP server) and this solved the problem on my part. No timeout errors ever since. – mblomdahl May 02 '14 at 17:43
  • 1
    @mblomdahl i actually solved it by setting the timeout for the ftp connection to 20 seconds and it seems to work for now. – aschmid00 May 02 '14 at 20:23
  • @Praxiteles I would assume so, though I haven't had the opportunity to try it. :-) – mblomdahl Jul 16 '14 at 08:46
  • No, "FTP is not supported.". Source: https://cloud.google.com/appengine/docs/java/sockets/ – Dr. Max Völkel Jul 04 '16 at 14:16
0

Write an ftp proxy and run it on Google Cloud Engine.

Guido van Rossum
  • 16,690
  • 3
  • 46
  • 49
0

Here are the FTP codes I have tested works on GAE (billing enabled)

Python

#!/usr/bin/env python
from google.appengine.ext import webapp
from ftplib import FTP

class HwHandler(webapp.RequestHandler):
    def get(self):
        self.response.out.write('FTP Starting...<br>')
        ftp = FTP('ftp_site.com') 
        ftp.login('login', 'password')
        ftp.set_pasv(False) 
        ftp.retrlines('LIST')  # list directory contents
        self.response.out.write('FTP opened')
        ftp.quit()

app = webapp.WSGIApplication([
    ('/', HwHandler)
 ], debug=True)

Php

<?php 
/* set the FTP hostname */ 
$user = "test"; 
$pass = "myFTP"; 
$host = "example.com"; 
$file = "test.txt"; 
$hostname = $user . ":" . $pass . "@" . $host . "/" . $file; 

/* the file content */ 
$content = "this is just a test."; 

/* create a stream context telling PHP to overwrite the file */ 
$options = array('ftp' => array('overwrite' => true)); 
$stream = stream_context_create($options); 

/* and finally, put the contents */ 
file_put_contents($hostname, $content, 0, $stream); 
?>

I will update later for Java & Go.

Community
  • 1
  • 1
eQ19
  • 9,880
  • 3
  • 65
  • 77
  • How can this even work? ```ftp.set_pasv(False)``` but we cannot create a listening socket in the sandboxed AppEngine... – CaptainPatate Aug 07 '15 at 09:49
-1

FTP is not what is available right now on AppEngine, but you can use a complicated solution.

  1. Export your data as a file to Google Cloud Storage. It is is easy using Appengine FileService. You can use AppEngine Pipelines library to manage this process.
  2. Create Google Compute Engine instance. It is a virtual machine where you can create sockets and use the sofware you need.
  3. Setup FTP server on your compute engine instance.
  4. Compute Engine have access to cloud storage so your can serve your files to third-party clients via FTP.

This is complicated process, but still it could help to solve your problem.

Kirill Lebedev
  • 650
  • 4
  • 9
  • Maybe a full App Engine solution will be available. See this post about App Engine Sockets Trusted Tester Program: http://googleappengine.blogspot.in/2012/09/app-engine-172-released.html – voscausa Oct 06 '12 at 18:20
  • No, "FTP is not supported.". Source: https://cloud.google.com/appengine/docs/java/sockets/ – Dr. Max Völkel Jul 04 '16 at 14:15