Module: Slack::Endpoint::Files

Included in:
Slack::Endpoint
Defined in:
lib/slack/endpoint/files.rb

Instance Method Summary collapse

Instance Method Details

#files_comments(options = {}) ⇒ Object

Edit an existing comment on a file. Only the user who created a comment may make edits. Teams may configure a limited time window during which file comment edits are allowed.

Parameters:

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

    a customizable set of options

Options Hash (options):

  • :file (Object)

    File containing the comment to edit.

  • :id (Object)

    The comment to edit.

  • :comment (Object)

    Text of the comment to edit.

See Also:



18
19
20
21
22
23
24
# File 'lib/slack/endpoint/files.rb', line 18

def files_comments(options={})
  throw ArgumentError.new("Required arguments :file missing") if options[:file].nil?
  throw ArgumentError.new("Required arguments :id missing") if options[:id].nil?
  throw ArgumentError.new("Required arguments :comment missing") if options[:comment].nil?
  options[:attachments] = options[:attachments].to_json if Hash === options[:attachments]
  post("files.comments", options)
end

#files_delete(options = {}) ⇒ Object

This method deletes a file from your team.

Parameters:

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

    a customizable set of options

Options Hash (options):

  • :file (Object)

    ID of file to delete.

See Also:



34
35
36
37
38
# File 'lib/slack/endpoint/files.rb', line 34

def files_delete(options={})
  throw ArgumentError.new("Required arguments :file missing") if options[:file].nil?
  options[:attachments] = options[:attachments].to_json if Hash === options[:attachments]
  post("files.delete", options)
end

#files_info(options = {}) ⇒ Object

This method returns information about a file in your team.

Parameters:

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

    a customizable set of options

Options Hash (options):

  • :file (Object)

    Specify a file by providing its ID.

  • :count (Object)

    Number of items to return per page.

  • :page (Object)

    Page number of results to return.

See Also:



52
53
54
55
56
# File 'lib/slack/endpoint/files.rb', line 52

def files_info(options={})
  throw ArgumentError.new("Required arguments :file missing") if options[:file].nil?
  options[:attachments] = options[:attachments].to_json if Hash === options[:attachments]
  post("files.info", options)
end

#files_list(options = {}) ⇒ Object

This method returns a list of files within the team. It can be filtered and sliced in various ways.

Parameters:

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

    a customizable set of options

Options Hash (options):

  • :user (Object)

    Filter files created by a single user.

  • :channel (Object)

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

  • :ts_from (Object)

    Filter files created after this timestamp (inclusive).

  • :ts_to (Object)

    Filter files created before this timestamp (inclusive).

  • :types (Object)

    Filter files by type:

    all - All files spaces - 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=spaces,snippets.The default value is all, which does not filter the list.

  • :count (Object)

    Number of items to return per page.

  • :page (Object)

    Page number of results to return.

See Also:



90
91
92
93
# File 'lib/slack/endpoint/files.rb', line 90

def files_list(options={})
  options[:attachments] = options[:attachments].to_json if Hash === options[:attachments]
  post("files.list", options)
end

#files_revokePublicURL(options = {}) ⇒ Object

This method disables public/external sharing for a file.

Parameters:

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

    a customizable set of options

Options Hash (options):

  • :file (Object)

    File to revoke

See Also:



103
104
105
106
107
# File 'lib/slack/endpoint/files.rb', line 103

def files_revokePublicURL(options={})
  throw ArgumentError.new("Required arguments :file missing") if options[:file].nil?
  options[:attachments] = options[:attachments].to_json if Hash === options[:attachments]
  post("files.revokePublicURL", options)
end

#files_sharedPublicURL(options = {}) ⇒ Object

This method enables public/external sharing for a file.

Parameters:

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

    a customizable set of options

Options Hash (options):

  • :file (Object)

    File to share

See Also:



117
118
119
120
121
# File 'lib/slack/endpoint/files.rb', line 117

def files_sharedPublicURL(options={})
  throw ArgumentError.new("Required arguments :file missing") if options[:file].nil?
  options[:attachments] = options[:attachments].to_json if Hash === options[:attachments]
  post("files.sharedPublicURL", options)
end

#files_startPartialUpload(options = {}) ⇒ Object

This is for starting the upload process of a file. It only requires a filename, and gives back a ticket ID so that later, the upload can be found and updated with all the remaining file info.

Parameters:

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

    a customizable set of options

Options Hash (options):

  • :file (Object)

    File contents via multipart/form-data.

See Also:



132
133
134
135
# File 'lib/slack/endpoint/files.rb', line 132

def files_startPartialUpload(options={})
  options[:attachments] = options[:attachments].to_json if Hash === options[:attachments]
  post("files.startPartialUpload", options)
end

#files_upload(options = {}) ⇒ Object

This method allows you to create or upload an existing file.

Parameters:

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

    a customizable set of options

Options Hash (options):

  • :file (Object)

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

  • :content (Object)

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

  • :filetype (Object)

    A file type identifier.

  • :filename (Object)

    Filename of file.

  • :title (Object)

    Title of file.

  • :initial_comment (Object)

    Initial comment to add to file.

  • :channels (Object)

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

See Also:



157
158
159
160
161
# File 'lib/slack/endpoint/files.rb', line 157

def files_upload(options={})
  throw ArgumentError.new("Required arguments :filename missing") if options[:filename].nil?
  options[:attachments] = options[:attachments].to_json if Hash === options[:attachments]
  post("files.upload", options)
end