slack-ruby-client
slack-ruby-client copied to clipboard
After `client.files_upload`, `message.file.size != message.file["size"]`
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?
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.