Slack v0.9.0 Slack.Web.Files

Summary

Functions

Add a comment to an existing file

Deletes an existing comment on a file

Gets information about a team file

Lists & filters team files

Revokes public/external sharing access for a file

Enables a file for public/external sharing

Functions

comments/add(comment, file, optional_params \\ %{})

Add a comment to an existing file.

Required Params

  • comment - Text of the comment to add. ex: Everyone should take a moment to read this file.
  • file - File to add a comment to. ex: F1234567890

Errors the API can return:

  • file_deleted - The requested file was previously deleted.
  • file_not_found - The requested file could not be found.
  • no_comment - The comment field was empty.
comments/delete(file, id, optional_params \\ %{})

Deletes an existing comment on a file.

Required Params

  • file - File to delete a comment from. ex: F1234567890
  • id - The comment to delete. ex: Fc1234567890

Errors the API can return:

  • cant_delete - The requested comment could not be deleted.
  • file_deleted - The requested file was previously deleted.
  • file_not_found - The requested file could not be found.
comments/edit(comment, file, id, optional_params \\ %{})

Edit an existing file comment.

Required Params

  • comment - Text of the comment to edit. ex: Everyone should take a moment to read this file, seriously.
  • file - File containing the comment to edit. ex: F1234567890
  • id - The comment to edit. ex: Fc1234567890

Errors the API can return:

  • cant_edit - The requested file could not be found.
  • edit_window_closed - The timeframe for editing the comment has expired.
  • file_deleted - The requested file was previously deleted.
  • file_not_found - The requested file could not be found.
  • no_comment - The comment field was empty.
delete(file, optional_params \\ %{})

Deletes a file.

Required Params

  • file - ID of file to delete.

Errors the API can return:

  • cant_delete_file - Authenticated user does not have permission to delete this file.
  • file_deleted - The file has already been deleted.
  • file_not_found - The file does not exist, or is not visible to the calling user.
info(file, optional_params \\ %{})

Gets information about a team file.

Required Params

  • file - Specify a file by providing its ID. ex: F2147483862

Errors the API can return:

  • file_deleted - The requested file has been deleted
  • file_not_found - Value passed for file was invalid
list(optional_params \\ %{})

Lists & filters team files.

Optional Params

  • channel - Filter files appearing in a specific channel, indicated by its ID.
  • ts_from - Filter files created after this timestamp (inclusive). ex: 123456789
  • ts_to - Filter files created before this timestamp (inclusive). ex: 123456789
  • types - Filter files by type:

  • all - All files
  • posts - Posts
  • snippets - Snippets
  • images - Image files
  • gdocs - Google docs
  • zips - Zip files
  • pdfs - PDF files

You can pass multiple values in the types argument, like types=posts,snippets.The default value is all, which does not filter the list. ex: images

  • user - Filter files created by a single user.

Errors the API can return:

  • unknown_type - Value passed for types was invalid
  • user_not_found - Value passed for user was invalid
revoke_public_url(file, optional_params \\ %{})

Revokes public/external sharing access for a file

Required Params

  • file - File to revoke

Errors the API can return:

  • file_not_found - Value passed for file was invalid
shared_public_url(file, optional_params \\ %{})

Enables a file for public/external sharing.

Required Params

  • file - File to share

Errors the API can return:

  • file_not_found - Value passed for file was invalid
  • not_allowed - Public sharing has been disabled for this team
upload(file, filename, optional_params \\ %{})

Uploads or creates a file.

Required Params

  • file - File contents via multipart/form-data. ex: ...
  • filename - Filename of file. ex: foo.txt

Optional Params

  • channels - Comma-separated list of channel names or IDs where the file will be shared.
  • content - File contents via a POST var. ex: ...
  • filetype - Slack-internal file type identifier. ex: php
  • initial_comment - Initial comment to add to file. ex: Best!
  • title - Title of file. ex: My File

Errors the API can return:

  • invalid_channel - One or more channels supplied are invalid
  • posting_to_general_channel_denied - An admin has restricted posting to the #general channel.