Slack - How to upload a file with a mode other than snippet through API

1.2k views Asked by At

I am attempting to load files to a slack channel automatically from a server via the API, but I'm running up against the 1MB limit for snippets. Is there a way to use file.upload to post files as either hosted or post?

Here's the curl command I'm testing with:

 curl -F file=$FILE_PATH -F channels=$CHANNEL_ID \
         -F token=$TOKEN -F filename=$SLACK_FILE_NAME \
         $SLACK ADDRESS -x $PROXY_SERVER

This successfully posts the file to the channel, but the mode is snippet which means it's not a particularly elegant looking interface in slack and subject to the very small 1MB limit.

EDIT:

When posting the file through the API here is the response that I am getting back (with potentially sensitive information sanitized):

{"ok":true,
"file":{"id":ID_NBR,
"created":1529417913,
"timestamp":1529417913,
"name":FILE_NAME,
"title":FILE_TITLE,
"mimetype":"text\/csv",
"filetype":"csv",
"pretty_type":"CSV",
"user":USER_ID,
"editable":true,
"size":74810,
"mode":"snippet",   ###### This is where I see the mode snippet through APIs, in channel it appears as a snippet as well ######
"is_external":false,
"external_type":"",
"is_public":true,
"public_url_shared":false,
"display_as_bot":false,"username":"",
"url_private":URL,
"url_private_download":URL,
"permalink":URL,
"permalink_public":URL,
"edit_link":URL,
"preview":FILE_DATA,
"preview_highlight":"<div class=\"CodeMirror cm-s-default CodeMirrorServer\" oncopy=\"if(event.clipboardData){event.clipboardData.setData('text\/plain',window.getSelection().toString().replace(\/\\u200b\/g,''));event.preventDefault();event.stopPropagation();}\">\n<div class=\"CodeMirror-code\">\n<div><pre>FILE_DATA<\/pre><\/div>\n<\/div>\n<\/div>\n",
"lines":202,
"lines_more":201,
"preview_is_truncated":true,
"channels":[CHANNEL_IDS],
"groups":[],
"ims":[],
"comments_count":0}}
0

There are 0 answers