首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Ruby hipchat gem无效发送文件

Ruby hipchat gem无效发送文件
EN

Stack Overflow用户
提问于 2017-06-02 02:17:50
回答 2查看 31关注 0票数 0

所以这与我之前在method上发表的一篇文章有关。这基本上就是我用来通过hipchat发送文件的方式:

代码语言:javascript
复制
#!/usr/bin/env ruby
require 'hipchat'

client = HipChat::Client.new('HIPCHAT_TOKEN', :api_version => 'v2', :server_url => 'HIPCHAT_URL')
client.user('some_username').send_file('message', File.open('./output/some-file.csv') )
client['some_hipchat_room'].send_file('some_user', 'message', File.open('./output/some-file.csv') ) 

现在,由于某些原因,send_file方法无效:

代码语言:javascript
复制
/path/to/gems/hipchat-1.5.4/lib/hipchat/errors.rb:40:in `response_code_to_exception_for': You requested an invalid method. path:https://hipchat.illum.io/v2/user/myuser@myemail/share/file?auth_token=asdfgibberishasdf method:Net::HTTP::Get (HipChat::MethodNotAllowed)
    from /path/to/gems/gems/hipchat-1.5.4/lib/hipchat/user.rb:50:in `send_file'
EN

回答 2

Stack Overflow用户

发布于 2017-06-02 04:46:13

我认为这表明你应该使用POST而不是GET,但我不确定,因为我没有使用过这个库或Hipchat。

查看question you referencedthe source posted by another user,它们使用self.class.post发送请求,您的调试输出显示为Net::HTTP::Get

为了调试,你能试一下吗,

代码语言:javascript
复制
file = Tempfile.new('foo').tap do |f|
  f.write("the content")
  f.rewind
end

user = client.user(some_username)
user.send_file('some bytes', file)
票数 0
EN

Stack Overflow用户

发布于 2017-06-03 05:13:03

问题是我试图通过http而不是https连接到服务器。如果以下客户端导致问题:

代码语言:javascript
复制
client = HipChat::Client.new('HIPCHAT_TOKEN', :api_version => 'v2', :server_url => 'my.company.com')

然后尝试将https://添加到您公司名称的开头。

代码语言:javascript
复制
client = HipChat::Client.new('HIPCHAT_TOKEN', :api_version => 'v2', :server_url => 'https://my.company.com')
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44314481

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档