Module: Slack::Web::Api::Endpoints::Files

Included in:
Slack::Web::Api::Endpoints
Defined in:
lib/slack/web/api/endpoints/files.rb

Instance Method Summary collapse

Instance Method Details

#files_completeUploadExternal(options = {}) ⇒ Object

Finishes an upload started with files.getUploadURLExternal

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :files (array)

    Array of file ids and their corresponding (optional) titles.

  • :channel_id (Object)

    Channel ID where the file will be shared. If not specified the file will be private.

  • :initial_comment (string)

    The message text introducing the file in specified channels.

  • :thread_ts (string)

    Provide another message’s ts value to upload this file as a reply. Never use a reply’s ts value; use its parent instead.

Raises:

  • (ArgumentError)

See Also:



22
23
24
25
# File 'lib/slack/web/api/endpoints/files.rb', line 22

def files_completeUploadExternal(options = {})
  raise ArgumentError, 'Required arguments :files missing' if options[:files].nil?
  post('files.completeUploadExternal', options)
end

#files_delete(options = {}) ⇒ Object

Deletes a file.

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :file (file)

    ID of file to delete.

Raises:

  • (ArgumentError)

See Also:



34
35
36
37
# File 'lib/slack/web/api/endpoints/files.rb', line 34

def files_delete(options = {})
  raise ArgumentError, 'Required arguments :file missing' if options[:file].nil?
  post('files.delete', options)
end

#files_edit(options = {}) ⇒ Object

Change the properties of a file (undocumented)

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :file (Object)

    ID of the file to be edited

  • :title (Object)

    New title of the file

  • :filetype (Object)

    New filetype of the file. See api.slack.com/types/file#file_types for a list of all supported types.

Raises:

  • (ArgumentError)

See Also:



49
50
51
52
53
54
# File 'lib/slack/web/api/endpoints/files.rb', line 49

def files_edit(options = {})
  raise ArgumentError, 'Required arguments :file missing' if options[:file].nil?
  raise ArgumentError, 'Required arguments :title missing' if options[:title].nil?
  logger.warn('The files.edit method is undocumented.')
  post('files.edit', options)
end

#files_getUploadURLExternal(options = {}) ⇒ Object

Gets a URL for an edge external file upload

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :filename (string)

    Name of the file being uploaded.

  • :length (integer)

    Size in bytes of the file being uploaded.

  • :alt_txt (string)

    Description of image for screen-reader.

  • :snippet_type (string)

    Syntax type of the snippet being uploaded.

Raises:

  • (ArgumentError)

See Also:



69
70
71
72
73
# File 'lib/slack/web/api/endpoints/files.rb', line 69

def files_getUploadURLExternal(options = {})
  raise ArgumentError, 'Required arguments :filename missing' if options[:filename].nil?
  raise ArgumentError, 'Required arguments :length missing' if options[:length].nil?
  post('files.getUploadURLExternal', options)
end

#files_info(options = {}) ⇒ Object

Gets information about a file.

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :file (file)

    Specify a file by providing its ID.

  • :cursor (string)

    Parameter for pagination. File comments are paginated for a single file. Set cursor equal to the next_cursor attribute returned by the previous request’s response_metadata. This parameter is optional, but pagination is mandatory: the default value simply fetches the first “page” of the collection of comments. See pagination for more details.

  • :limit (integer)

    The maximum number of items to return. Fewer than the requested number of items may be returned, even if the end of the list hasn’t been reached.

Raises:

  • (ArgumentError)

See Also:



86
87
88
89
90
91
92
93
94
95
# File 'lib/slack/web/api/endpoints/files.rb', line 86

def files_info(options = {})
  raise ArgumentError, 'Required arguments :file missing' if options[:file].nil?
  if block_given?
    Pagination::Cursor.new(self, :files_info, options).each do |page|
      yield page
    end
  else
    post('files.info', options)
  end
end

#files_list(options = {}) ⇒ Object

List for a team, in a channel, or from a user with applied filters.

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :channel (channel)

    Filter files appearing in a specific channel, indicated by its ID.

  • :show_files_hidden_by_limit (boolean)

    Show truncated file info for files hidden due to being too old, and the team who owns the file being over the file limit.

  • :team_id (string)

    encoded team id to list files in, required if org token is used.

  • :ts_from (string)

    Filter files created after this timestamp (inclusive).

  • :ts_to (string)

    Filter files created before this timestamp (inclusive).

  • :types (string)

    Filter files by type (see below). You can pass multiple values in the types argument, like types=spaces,snippets.The default value is all, which does not filter the list.

  • :user (user)

    Filter files created by a single user.

See Also:



116
117
118
119
120
# File 'lib/slack/web/api/endpoints/files.rb', line 116

def files_list(options = {})
  options = options.merge(channel: conversations_id(options)['channel']['id']) if options[:channel]
  options = options.merge(user: users_id(options)['user']['id']) if options[:user]
  post('files.list', options)
end

#files_revokePublicURL(options = {}) ⇒ Object

Revokes public/external sharing access for a file

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :file (file)

    File to revoke.

Raises:

  • (ArgumentError)

See Also:



129
130
131
132
# File 'lib/slack/web/api/endpoints/files.rb', line 129

def files_revokePublicURL(options = {})
  raise ArgumentError, 'Required arguments :file missing' if options[:file].nil?
  post('files.revokePublicURL', options)
end

#files_share(options = {}) ⇒ Object

Share an existing file in a channel (undocumented)

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :file (Object)

    ID of the file to be shared

  • :channel (channel)

    Channel to share the file in. Works with both public (channel ID) and private channels (group ID).

Raises:

  • (ArgumentError)

See Also:



142
143
144
145
146
147
148
# File 'lib/slack/web/api/endpoints/files.rb', line 142

def files_share(options = {})
  raise ArgumentError, 'Required arguments :file missing' if options[:file].nil?
  raise ArgumentError, 'Required arguments :channel missing' if options[:channel].nil?
  options = options.merge(channel: conversations_id(options)['channel']['id']) if options[:channel]
  logger.warn('The files.share method is undocumented.')
  post('files.share', options)
end

#files_sharedPublicURL(options = {}) ⇒ Object

Enables a file for public/external sharing.

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :file (file)

    File to share.

Raises:

  • (ArgumentError)

See Also:



157
158
159
160
# File 'lib/slack/web/api/endpoints/files.rb', line 157

def files_sharedPublicURL(options = {})
  raise ArgumentError, 'Required arguments :file missing' if options[:file].nil?
  post('files.sharedPublicURL', options)
end

#files_upload(options = {}) ⇒ Object

Uploads or creates a file.

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :channels (string)

    Comma-separated list of channel names or IDs where the file will be shared.

  • :content (string)

    File contents via a POST variable. If omitting this parameter, you must provide a file.

  • :file (file)

    File contents via multipart/form-data. If omitting this parameter, you must submit content.

  • :filename (string)

    Filename of file.

  • :filetype (string)

    A file type identifier.

  • :initial_comment (string)

    The message text introducing the file in specified channels.

  • :thread_ts (string)

    Provide another message’s ts value to upload this file as a reply. Never use a reply’s ts value; use its parent instead.

  • :title (string)

    Title of file.

See Also:



183
184
185
# File 'lib/slack/web/api/endpoints/files.rb', line 183

def files_upload(options = {})
  post('files.upload', options)
end