asonas / chatwork-ruby

MIT License
64 stars 27 forks source link

Add file upload method #55

Closed sue445 closed 6 years ago

sue445 commented 6 years ago

Close #54

sue445 commented 6 years ago

i implemented a file uploading method, but doesn't work...

Example

File counts before file uploading

[1] pry(main)> ChatWork::File.get(room_id: 11111111, account_id: 1111111).count
=> 1

Upload a file

[2] pry(main)> ChatWork::File.create(room_id: 11111111, message: "test", file: Faraday::UploadIO.new("spec/data/upload.txt", "text/plain"))
=> {"file_id"=>268334131}

API is Successful

File counts after file uploading

[3] pry(main)> ChatWork::File.get(room_id: 11111111, account_id: 1111111).count
=> 1

[4] pry(main)> ChatWork::File.find(room_id: 11111111, file_id: 268334131)
=> {"file_id"=>268334131,
 "message_id"=>"",
 "filesize"=>424,
 "filename"=>"default.dat",
 "upload_time"=>1531843944,
 "account"=>{"account_id"=>1111111, "name"=>"sue445", "avatar_image_url"=>"https://appdata.chatwork.com/avatar/2170/2170448.rsz.png"}}

File counts is not changed :cold_sweat: