我正在尝试使用ruby1.8进行文件上传,但似乎没有好的开箱即用的解决方案。它们似乎都需要一些第三方补丁或项目分支才能工作。我会使用机械化,但实际上我需要与xml接口,而机械化似乎是专门为直接处理网页而设计的。我已经尝试过RestClient,但它没有开箱即用的多部分表单功能,你必须使用项目的分支才能让它工作。Net似乎也存在类似的情况:HTTP我认为抑制可能是可行的,因为我可能想要使用多curb来做一些我计划做的其他事情。然而,在我的视窗机器上,我似乎无法安装路缘宝石。gem install where给出了一个错误,说我需要指定curl库所在的位置。我尝试过将选项传递给extconf,但到目前为止没有成功。以下是不带任何选项的gem install路缘的输出
C:\ruby\lib\ruby\gems\1.8\gems\curb-0.5.4.0>gem install curb
Building native extensions. This could take a while...
ERROR: Error installing curb:
ERROR: Failed to build gem native extension.
C:/ruby/bin/ruby.exe extconf.rb
checking for curl-config... no
checking for main() in curl.lib... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--srcdir=.
--curdir
--ruby=C:/ruby/bin/ruby
--with-curl-dir
--without-curl-dir
--with-curl-include
--without-curl-include=${curl-dir}/include
--with-curl-lib
--without-curl-lib=${curl-dir}/lib
--with-curllib
--without-curllib
extconf.rb:12: Can't find libcurl or curl/curl.h (RuntimeError)
Try passing --with-curl-dir or --with-curl-lib and --with-curl-include
options to extconf.
Gem files will remain installed in C:/ruby/lib/ruby/gems/1.8/gems/curb-0.5.4.0 for inspection.
Results logged to C:/ruby/lib/ruby/gems/1.8/gems/curb-0.5.4.0/ext/gem_make.out你知道我怎么才能让它工作吗?
发布于 2010-08-23 13:47:57
正如我已经评论过的,我确实找到了一个简单地使用github gem中提供的rest-client的解决方案。gem install rest-client将完成这项工作。从那里你可以做一个多部分的帖子,它可以包含一个或多个文件。它具有rest客户端所需的所有灵活性。有关如何使用它的示例,请参阅此处的文档:http://rdoc.info/projects/archiloque/rest-client。
我发现它唯一不能正确执行的事情就是解析cookie。我的公司使用的cookie在值中可能有等号,并且不能正确地解析它们。我用了一些技巧来绕过这个问题,但最终还是被它咬了。所以就在前几天,我开始分析来自Mechanize/WEBrick的代码,并且能够利用来自Mechanize的CookieJar来管理来自rest客户端的cookie。希望我能让rest-client的作者将此功能构建到rest-client中,这样其他人就不会遇到与我相同的问题。
发布于 2010-07-06 12:55:34
马特
我以前在Windows中安装路缘宝石时遇到过问题。在尝试了解其他人是如何解决这个问题的过程中,我遇到了很多问题,但解决方案不是很多。今晚我不得不再做一次,我决定记录我的步骤并发布结果:http://beginrescue.blogspot.com/2010/07/installing-curb-with-ruby-191-in.html
对不起,博客垃圾邮件,希望这是有用的人。
皮特
发布于 2012-03-28 04:55:52
最终,在Ruby1.9.1的win7中,以下方法对我有效(路径需要更新以反映您的curl版本(可以通过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"这确实需要几分钟的时间来处理,所以请耐心等待。
https://stackoverflow.com/questions/1511865
复制相似问题