slack-ruby-client icon indicating copy to clipboard operation
slack-ruby-client copied to clipboard

After `client.files_upload`, `message.file.size != message.file["size"]`

Open rangerscience opened this issue 6 years ago • 1 comments

      message = client.files_upload(
        channels: '\#dev',
        as_user: true,
        file: UploadIO.new('./test.txt', 'text/plain'),
        title: 'test.txt',
        filename: 'test.txt',
        initial_comment: 'testing'
      )
      File.open('./test.txt').size # 27
      message.file.size # 35
      message.file["size"] # 27

message.file.size is then different from message.file["size"]. The latter is both what is shown when printing message.file to the console, and appears to be the actual size of the file. Not sure what the former actually is.

What's going on? Should this be what's going on?

rangerscience avatar Jul 30 '19 19:07 rangerscience

This is a problem.

We wrap responses with a Hashie::Mash and what you're getting is the size of the hash instead of the value in it. You should write a spec to demonstrate it and we can see if we can fix it. I suspect that for the responses where we know there's a .size we can implement that method explicitly.

dblock avatar Jul 31 '19 14:07 dblock