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.

  • :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. Also make sure to provide only one channel when using ‘thread_ts’.

  • :channels (string)

    Comma-separated string of channel IDs or user IDs where the file will be shared.

  • :initial_comment (string)

    The message text introducing the file in specified channels.

  • :blocks (string)

    A JSON-based array of structured rich text blocks, presented as a URL-encoded string. If the initial_comment field is provided, the blocks field is ignored.

Raises:

  • (ArgumentError)

See Also:



26
27
28
29
30
# File 'lib/slack/web/api/endpoints/files.rb', line 26

def files_completeUploadExternal(options = {})
  raise ArgumentError, 'Required arguments :files missing' if options[:files].nil?
  options = encode_options_as_json(options, i[blocks])
  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:



39
40
41
42
# File 'lib/slack/web/api/endpoints/files.rb', line 39

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:



54
55
56
57
58
59
# File 'lib/slack/web/api/endpoints/files.rb', line 54

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):

  • :length (integer)

    Size in bytes of the file being uploaded.

  • :filename (string)

    Name of the file being uploaded.

  • :snippet_type (string)

    Syntax type of the snippet being uploaded.

  • :alt_txt (string)

    Description of image for screen-reader.

Raises:

  • (ArgumentError)

See Also:



74
75
76
77
78
# File 'lib/slack/web/api/endpoints/files.rb', line 74

def files_getUploadURLExternal(options = {})
  raise ArgumentError, 'Required arguments :length missing' if options[:length].nil?
  raise ArgumentError, 'Required arguments :filename missing' if options[:filename].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):

  • :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.

  • :file (file)

    Specify a file by providing its ID.

  • :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:



91
92
93
94
95
96
97
98
99
100
# File 'lib/slack/web/api/endpoints/files.rb', line 91

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:



121
122
123
124
125
# File 'lib/slack/web/api/endpoints/files.rb', line 121

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:



134
135
136
137
# File 'lib/slack/web/api/endpoints/files.rb', line 134

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:



147
148
149
150
151
152
153
# File 'lib/slack/web/api/endpoints/files.rb', line 147

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:



162
163
164
165
# File 'lib/slack/web/api/endpoints/files.rb', line 162

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:



188
189
190
# File 'lib/slack/web/api/endpoints/files.rb', line 188

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