Error with file upload/slack API
levidps opened this issue · comments
Upon trying to upload an .apk
file I came across and error between the plugin and slacks API. In the plugin file it's passing in a file name minus the file type suffix however when reviewing the slack API the suffix is required when supplying a file name. The result is when uploading an apk you get the following API call:
file_path: "./dev/release/output/flavour/my-apk.apk
# file_upload_to_slack.rb
# Slack upload params - currently missing suffix from filename
filename: "my-apk",
filetype: "apk",
This results in slack trying to guess the file type and for apks they fall back to .zip
- which isn't correct since APK is a supported file type. This can be worked around currently by ensuring we supply a file_name: ...#{type}
however the plugin should be smart enough to actually append the suffix to file name (or not strip it in the first place).
# Expected payload
filename: "my-apk.apk",
filetype: "apk",
Hi @levidps
This looks like a bug to me indeed, thank you for reporting! 😇
are you blocked at the moment, or did you manage to unblock yourself using a workaround?
I will open PR soon and let you know to test once that PR before merging into master. thanks again!
@crazymanish I was able to get a workaround by specifying the file_type
and file_name
in the file_upload_to_slack()
method. It works fine but just required explicitly setting file name/type correctly.
I had a similar issue, set the code as follows and it worked. Note originally I also had the issue that files.write
wasn't an allowed permission on my slack app, which, wasn't apparent until I manually tried to curl the API URL to test.
file_upload_to_slack(
api_token: ENV["SLACK_API_TOKEN"],
file_path: "./sentry.properties",
file_name: "sentry.properties",
file_type: "properties",
channels: "#test"
)
As we have a working workaround. closing it.