mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-10 04:30:32 -07:00
feat(slack) : Add file upload functionality
This commit is contained in:
parent
ce23364700
commit
56e306506b
1 changed files with 12 additions and 5 deletions
|
@ -607,11 +607,18 @@ def upload_file_to_slack(module, token, channel, file_upload):
|
|||
module.fail_json(
|
||||
msg="Error during upload completion: %s (HTTP %s)" % (info['msg'], info['status'])
|
||||
)
|
||||
upload_url_data = json.load(response)
|
||||
except ValueError:
|
||||
module.fail_json(
|
||||
msg="The Slack API response is not valid JSON: %s" % response.read()
|
||||
)
|
||||
try:
|
||||
upload_url_data = json.load(response)
|
||||
except ValueError:
|
||||
module.fail_json(
|
||||
msg="The Slack API response is not valid JSON: %s" % response.read()
|
||||
)
|
||||
if not upload_url_data.get("ok"):
|
||||
module.fail_json(
|
||||
msg="Failed to complete the upload: %s" % upload_url_data
|
||||
)
|
||||
except Exception as e:
|
||||
module.fail_json(msg="Error uploading file: %s" % str(e))
|
||||
if not upload_url_data.get("ok"):
|
||||
module.fail_json(msg="Failed to complete the upload: %s" % upload_url_data)
|
||||
return upload_url_data
|
||||
|
|
Loading…
Add table
Reference in a new issue