FTP **TO** Heroku 上托管的 Rails 应用程序?
请原谅这个奇怪的问题,但是有没有办法让我的 Rails 应用程序接收 FTP 传输?
我每天都有 FTP 上传,但我无法控制,每天都会将数百个 HTML 页面上传到我们现有的服务器。我想将此站点移至 Heroku 上的仅 Rails 部署,但我无法触及此 FTP 上传(这仍然需要发生)。
由于 Heroku 不提供公共存储空间或 FTP,因此我无法将文件直接上传到 Heroku(而且我真的不想这样做)。我想要的是将 FTP 上传指向我的 Rails 应用程序,然后让我的 Rails 应用程序接收并解析 HTML 文件以提取我需要的信息,将其存储在数据库中,并执行我需要执行的任何其他操作。 (有点像 RESTful 操作,但通过 FTP 而不是任何标准 REST 动词)。
这有可能吗,还是我因为这样想而发疯?如果可能的话,我将如何去做呢?
Pardon the whacky question, but is there anyway to have my Rails app receive a FTP transmission?
I have daily FTP upload that I have no control over, which uploads several hundred HTML pages to our existing server each day. I want to move this site to a Rails-only deployment on Heroku, but I can't touch this FTP upload (which still needs to happen).
Since Heroku doesn't offer public storage space or FTP, I can't upload the files directly to Heroku (and I don't really want to). What I would love is to point the FTP upload to my Rails app, and have my Rails app receive and parse the HTML files to pull out the information I need, store it in the database, and do whatever else I need to do with it. (Kinda like a RESTful action, but via FTP instead of any of the standard REST verbs).
Is this at all possible or am I barking mad for thinking it? If it is possible, how would I go about doing this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
我还需要一个 Heroku 实例来通过 FTP 接收文件。
我正在考虑使用 Brick FTP。
当 webhook 发出文件已上传信号时,我计划下载文件内容并将其导入数据库。
I also need a Heroku instance to receive files via FTP.
I am considering using Brick FTP.
When a webhook signals that a file has been uploaded I plan to download and import the file contents into the database.
FTP 不支持主机标头,因此您将很难将请求发送到 Heroku 网格和我想象的应用程序。
我更倾向于将您的文件发送到 Amazon S3 存储桶,并让您的应用程序从那里获取文件并以这种方式处理它们,或者类似地让您的应用程序访问 FTP 服务器并检索文件以这种方式进行处理。
FTP does not support host headers so you'll struggle getting your request into the Heroku grid and to your application I would imagine.
I would be more inclined to get your files to an Amazon S3 bucket and have your application get the files from there and process them that way, or similarly have your application reach out to the FTP server and retrieve the files for processing that way.
是的,这应该是可能的。您需要研究
net/ftp
模块并检查其工作原理,但这应该是可能的。我发现这个项目可能可以作为一个例子。
Yep this should be possible. You'll need to look into the
net/ftp
module and check out how that works but it should be possible.I've found this project that could probably serve as an example.
您可以使用 cron 安排 rake 任务,该任务将检索 ftp 服务器上的文件并将它们上传到您的数据库中。
您的 cron.rake 文件应如下所示:
请记住两件事:
You can schedule a rake task with cron which will retrieve files on the ftp server and upload them in your db.
Here is how your cron.rake file should look like:
Two things to keep in mind:
ftp.passive = true
since Heroku does not support active mode.Heroku 不支持您的应用程序接收 FTP。
如果您确实想要的话,您可以围绕接收 FTP 编写一个 Heroku 插件。
Heroku does not support your application receiving FTP.
You could possibly write a Heroku addon around receiving FTP, if you really want it.