Install Ruby Curb gem in windows XP

后端 未结 11 825
无人及你
无人及你 2020-12-15 12:29

I\'m trying to do file uploads with ruby 1.8 and it seems like there are no good out-of-the-box solutions. They all seem to need some 3rd party patch or fork of a project to

相关标签:
11条回答
  • 2020-12-15 12:50

    Looking at the underlying issue you are trying to solve. I was looking for a multpart-post client before and spent a lot of time trying out diffrent gems/tools. The only one i found that worked satisfactory was Nick Siegers multipart-post gem

    It was very straightforward to use, I highly recommend it.

    Here is sample code i made for my test

    require "rubygems"
    require 'net/http/post/multipart'
    
    url = URI.parse('http://localhost:3000/mytest/1.xml')
    File.open("c:/temp/readme.txt") do |jpg|
      req = Net::HTTP::Put::Multipart.new url.path,
        "mytest[attachment]" => UploadIO.new(jpg, "text/plain", "c:/temp/readme.txt")
      res = Net::HTTP.start(url.host, url.port) do |http|
        http.request(req)
      end
      puts res.inspect
    end
    
    0 讨论(0)
  • 2020-12-15 12:51

    Execute Below command and its works

    gem install curb --platform=mswin32

    0 讨论(0)
  • 2020-12-15 12:54

    Ultimately, in win7 with ruby 1.9.1 the following worked for me (where paths need to be updated to reflect the location (and version) of your curl version (which can be obtained via http://curl.haxx.se/download.html#Win32))

    gem install curb -- --with-curl-lib="C:/curl/curl-7.21.1-devel-mingw32/bin" --with-curl-include="C:/curl/curl-7.21.1-devel-mingw32/include"
    

    This did take a few minutes to process, so be patient.

    0 讨论(0)
  • 2020-12-15 12:56

    When you say you passed configuration options to extconf.rb, did you mean in the gem install command?

    If not, I believe it would be something along the lines of

    gem install curb -- --with-curl-dir=dir

    It might be a different config option, but the -- is that bit you need to pass it configure options.

    0 讨论(0)
  • 2020-12-15 12:57

    For Windows 8 the command was:

    gem install curb -- --with-curl-lib=C:/Utils/curl-7.32.0-dev/lib64 --with-curl-include=C:/Utils/curl-7.32.0-dev/include
    

    And it nearly installs. Now there are "undefined reference" warnings/errors

    0 讨论(0)
提交回复
热议问题