小编Rob*_*bin的帖子

Ruby rest-client文件作为具有基本身份验证的多部分表单数据上载

我理解如何使用Ruby的rest-client使用基本身份验证来创建http请求

response = RestClient::Request.new(:method => :get, :url => @base_url + path, :user => @sid, :password => @token).execute
Run Code Online (Sandbox Code Playgroud)

以及如何将文件作为多部分表单数据发布

RestClient.post '/data', :myfile => File.new("/path/to/image.jpg", 'rb')
Run Code Online (Sandbox Code Playgroud)

但我似乎无法弄清楚如何将两者结合起来将文件发布到需要基本身份验证的服务器.有谁知道创建此请求的最佳方法是什么?

ruby post http basic-authentication rest-client

11
推荐指数
1
解决办法
2万
查看次数

在客户端上使用多个Meteor Method调用避免回调地狱

我有多个Meteor.calls,其中每个方法都取决于另一个Meteor方法的响应.

客户

Meteor.call('methodOne', function(err, resOne){
    if(!err){
        Meteor.call('methodTwo', resOne, function(err, resTwo){
            if(!err){
                Meteor.call('methodThree', resTwo, function(err, resThree){
                    if(err){
                        console.log(err);
                    }
                })
            }
        });
    }
});
Run Code Online (Sandbox Code Playgroud)

从Meteor的文档我知道

"调用客户端的方法是异步运行的,所以你需要传递一个回调来观察调用的结果."

我知道我可以在服务器上创建另一个Meteor方法来执行方法'methodOne','MethodTwo','MethodThree'使用Meteor.async包装,或者顺序没有回调.但是我担心这条路会导致我的流星方法变得臃肿和纠结,导致意大利面条代码.我宁愿保持每个Meteor方法只需要做一个工作,并找到一种更优雅的方式来链接客户端上的调用.任何想法,有没有办法在客户端使用Promises?

javascript asynchronous promise meteor

8
推荐指数
1
解决办法
3038
查看次数

如何编译Ruby C扩展并在Windows上链接libcurl

我正在尝试构建一个使用libcurl的Ruby C Extensions.到目前为止,我已经在Os X上成功构建了它.但是我在Windows开发方面经验不足,我不确定如何去做.

到目前为止,我可以通过遵循这些说明或多或少地使用Visual Studio命令提示符中的extconf.rb和nmake编译Ruby C Extensions

http://blogs.law.harvard.edu/hoanga/2006/12/14/getting-a-ruby-c-extension-to-compile-on-windows/

但是我的扩展链接libcurl,extconf.rb中有一行来检查这一点

# Make sure the cURL library is installed.
have_library("curl")
Run Code Online (Sandbox Code Playgroud)

在创建makefile时,我明白了

checking for main() in curl.lib... no
creating Makefile
Run Code Online (Sandbox Code Playgroud)

当我运行nmake时,我明白了

fatal error C1083: Cannot open include file: 'curl/curl.h': No such file or directory
Run Code Online (Sandbox Code Playgroud)

这是所有预期的,因为它没有安装.我已经下载了curl-7.26.0-devel-mingw64(我认为这适用于Windows 7)

我只是想在Windows环境中弄清楚我应该放置/ bin或/ include以便我的编译器可以找到它们.

c ruby windows nmake ruby-c-extension

3
推荐指数
1
解决办法
4034
查看次数