开发者

Upload a file to a Rails Application from a Ruby command-line application

I've been busy on a social networking site for developers for a while (like a mix of github and Facebook), and I want to implement a simple system to create repositories, like on github. For this, I want to create a command-line application in Ruby (not Rails), which will check if there were made any changes, then upload changed or new files. The social networking site is written in Ruby, using the Ruby on Rails Framework:

  DEVELOPER'S PC OR MAC                            SERVER
Command-line (Ruby, local) <-------> Social networking site (Rails, web)

For the Rails application, I currenly use the Paperclip plugin开发者_Go百科 for a browser uploader. For the command-line uploader, what do you think is the best way for uploading? Sockets, a http-library, SSH, e-mail, FTP, something else? The uploading process should be fast, and the files are not really bigger than 200kb (unless it's Brainfuck, but that aside), since it are just source-code files.


Haven't used it myself but HTTPClient looks promising for this:

http://dev.ctor.org/doc/httpclient/

From their HTTPClient docs:

File.open('/tmp/post_data') do |file|
  body = { 'upload' => file, 'user' => 'nahi' }
  res = clnt.post(uri, body)
end

Also just noticed there are plenty of other options described in a previous stack overflow posting

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜