我已经在Redmine官方网站上提出了这个问题,但我没有得到任何答案,也许我会有更多机会在这里.
我正在开发一个项目,我尝试通过添加一些功能来改进Redmine 的现有插件,以允许用户使用简单的表单在Redmine文档中上传他的Dropbox文件.Redmine已经有了这种可能性,所以我想使用Redmine源代码中已经定义的控制器和方法.
我在其中一个插件视图中有以下代码:
<% html_title "Reddrop - Sync" %>
<h2>Synchronisation page</h2>
<p>Please choose your file</p>
<%= form_tag({:controller => "documents", :action => "add_attachment", :id => @document}, :multipart => true) do %>
<%= file_field_tag 'attachments[dummy][file]', :id => nil, :multiple => true, :onchange => "addInputFiles(this)" %>
<%= submit_tag(value = "Sync this file with Redmine") %>
<% end %>
Run Code Online (Sandbox Code Playgroud)
我正在调用add_attachmentRedmine源代码中定义的"文档"控制器和方法.当我提交表单时,我收到以下错误:
ActionController::RoutingError (No route matches {:controller=>"documents", :action=>"add_attachment", :id=>nil}):
Run Code Online (Sandbox Code Playgroud)
如果它们是在Redmine源代码中定义的,是否可以通过插件调用这些控制器/方法?
如果是的话,也许您可以就如何配置我的路线提出一些建议?
我正在为Redmine平台开发插件,我想使用链接而不是表单将文件附加到文档(基本上上传文件),为此我在方法中创建POST请求.
我按照这里的说明,将内容类型设置application/octet-stream为请求,然后将文件内容放在请求正文中.
我在这个网站上看了很多帖子,我知道这经常被问到但是我无法正确地处理我的请求,我仍然会收到错误.这是我的代码:
uri = URI.parse("http://<my_server_IP_address>:3000/uploads.js")
http = Net::HTTP.new(uri.host, uri.port)
request = Net::HTTP::Post.new(uri.path, initheader = {'X-CSRF-Token' => form_authenticity_token, 'Content-Type' => 'application/octet-stream'})
file = File.new("/home/testFile.txt", 'rb')
request.body = file.read
@response = http.request(request)
Run Code Online (Sandbox Code Playgroud)
如您所见,我使用该form_authenticity_token方法在标头中设置CSRF令牌,但我仍然收到422错误.
Filter chain halted as :verify_authenticity_token rendered or redirected
Completed 422 Unprocessable Entity in 4.7ms (ActiveRecord: 0.0ms)
Run Code Online (Sandbox Code Playgroud)
我也试着把skip_before_filter :verify_authenticity_token我的控制器打开,尽管不推荐,但它也没有用.
你知道这里有什么问题吗?
注意:我正在使用Rails 3.2.16,Ruby 1.9.3-p392和Redmine 2.4.2
我正在使用Redmine插件,我创建了一个方法,我发送2个HTTP POST请求将文件附加到文档.
执行第一个请求后,我得到了一个Timeout::Error (Timeout::Error)请求已成功完成,这里是Webrick的错误代码
Timeout::Error (Timeout::Error):
/usr/local/lib/ruby/1.9.1/net/protocol.rb:146:in `rescue in rbuf_fill'
/usr/local/lib/ruby/1.9.1/net/protocol.rb:140:in `rbuf_fill'
/usr/local/lib/ruby/1.9.1/net/protocol.rb:122:in `readuntil'
/usr/local/lib/ruby/1.9.1/net/protocol.rb:132:in `readline'
/usr/local/lib/ruby/1.9.1/net/http.rb:2562:in `read_status_line'
/usr/local/lib/ruby/1.9.1/net/http.rb:2551:in `read_new'
/usr/local/lib/ruby/1.9.1/net/http.rb:1319:in `block in transport_request'
/usr/local/lib/ruby/1.9.1/net/http.rb:1316:in `catch'
/usr/local/lib/ruby/1.9.1/net/http.rb:1316:in `transport_request'
/usr/local/lib/ruby/1.9.1/net/http.rb:1293:in `request' rest-client (1.6.7) lib/restclient/net_http_ext.rb:51:in `request'
/usr/local/lib/ruby/1.9.1/net/http.rb:1286:in `block in request'
/usr/local/lib/ruby/1.9.1/net/http.rb:745:in `start'
/usr/local/lib/ruby/1.9.1/net/http.rb:1284:in `request'
...
...
Started POST "/uploads.json?attachment_id=1&filename=testFile.txt" for <server_IP_address> at 2014-04-02 09:15:28 +0200
Processing by AttachmentsController#upload as JSON
Parameters: {"attachment_id"=>"1", "filename"=>"testFile.txt"}
Current user: <user> (id=3)
Saving attachment '/home/user/Redmine/redmine-2.4.2/files/2014/04/140402091528_testFile.txt' (72 bytes)
Rendered attachments/upload.api.rsb (1.7ms)
Completed 201 Created in 87.9ms …Run Code Online (Sandbox Code Playgroud) 我正在尝试配置 CXF 总线,并为所有客户端设置通用超时。为此,我使用 HttpConduitFeature 并在初始配置期间将其添加到总线,如下所示:
@Configuration
public class CxfContext {
@Autowired
private SoapConfigurations soapConfigurations;
@Bean
public Bus bus() {
SpringBus b = new SpringBus();
List<Feature> features = ImmutableList.<Feature> builder() //
.add(loggingFeature()) //
.add(conduitFeature()) //
.build();
b.setFeatures(features);
return b;
}
private LoggingFeature loggingFeature() {
LoggingFeature f = new LoggingFeature();
f.setPrettyLogging(true);
f.setVerbose(true);
f.setLimit(-1);
return f;
}
private HttpConduitFeature conduitFeature() {
HttpConduitFeature feature = new HttpConduitFeature();
HttpConduitConfig conduitConfig = new HttpConduitConfig();
HTTPClientPolicy clientPolicy = new HTTPClientPolicy();
clientPolicy.setConnectionTimeout(10000);
clientPolicy.setReceiveTimeout(10000);
conduitConfig.setClientPolicy(clientPolicy);
feature.setConduitConfig(conduitConfig);
return feature;
} …Run Code Online (Sandbox Code Playgroud)