Class: Telerivet::StoredFile

Inherits:
Entity
  • Object
show all
Defined in:
lib/telerivet/storedfile.rb

Overview

Represents a file stored in a Telerivet project, such as a media attachment for outgoing messages.

Stored files are also automatically created for media attachments for incoming messages.

Files can be uploaded via project.uploadFile, then attached to outgoing messages by passing the file ID as a file_id item in the media parameter when sending a message or broadcast.

Fields:

- id (string, max 34 characters)
  * ID of the stored file
  * Read-only

- filename (string, max 127 characters)
  * Filename of the stored file
  * Updatable via API

- type
  * MIME type of the file
  * Read-only

- size (int)
  * Size of the file in bytes
  * Read-only

- description (string, max 1000 characters)
  * Description of the file
  * Updatable via API

- category
  * Category of the stored file
  * Allowed values: outgoing_media, incoming_media, call_audio, test_recording,
      script_module, icon
  * Read-only

- source
  * How the stored file was created
  * Allowed values: upload, recording, message, api
  * Read-only

- message_id
  * ID of the message associated with this file, if any. Files associated with a message
      are deleted automatically when the message is deleted.
  * Read-only

- sha256
  * SHA-256 hash of the file content (lowercase hex), if available
  * Read-only

- time_created (UNIX timestamp)
  * Time the file was created in Telerivet
  * Read-only

- user_id (string, max 34 characters)
  * ID of the Telerivet user who created the file (if applicable)
  * Read-only

- url
  * URL where the file content can be downloaded. Note: this URL is temporary and may
      not be valid for more than 1 day; retrieve the stored file again to get a fresh URL.
  * Read-only

- thumbnail_url
  * URL of a thumbnail image for video files, if available. Note: this URL is temporary
      and may not be valid for more than 1 day.
  * Read-only

- project_id
  * ID of the project this file belongs to
  * Read-only

Instance Method Summary collapse

Methods inherited from Entity

#get, #initialize, #load, #set, #set_data, #to_s, #vars

Constructor Details

This class inherits a constructor from Telerivet::Entity

Instance Method Details

#categoryObject



125
126
127
# File 'lib/telerivet/storedfile.rb', line 125

def category
    get('category')
end

#deleteObject

Deletes this stored file.

A stored file may only be deleted by the user who created it or by a project administrator, and may not be deleted while it is attached to an existing message.



93
94
95
# File 'lib/telerivet/storedfile.rb', line 93

def delete()
    @api.do_request("DELETE", get_base_api_path())
end

#descriptionObject



117
118
119
# File 'lib/telerivet/storedfile.rb', line 117

def description
    get('description')
end

#description=(value) ⇒ Object



121
122
123
# File 'lib/telerivet/storedfile.rb', line 121

def description=(value)
    set('description', value)
end

#filenameObject



101
102
103
# File 'lib/telerivet/storedfile.rb', line 101

def filename
    get('filename')
end

#filename=(value) ⇒ Object



105
106
107
# File 'lib/telerivet/storedfile.rb', line 105

def filename=(value)
    set('filename', value)
end

#get_base_api_pathObject



161
162
163
# File 'lib/telerivet/storedfile.rb', line 161

def get_base_api_path()
    "/projects/#{get('project_id')}/files/#{get('id')}"
end

#idObject



97
98
99
# File 'lib/telerivet/storedfile.rb', line 97

def id
    get('id')
end

#message_idObject



133
134
135
# File 'lib/telerivet/storedfile.rb', line 133

def message_id
    get('message_id')
end

#project_idObject



157
158
159
# File 'lib/telerivet/storedfile.rb', line 157

def project_id
    get('project_id')
end

#saveObject

Saves any fields that have changed for this stored file.



83
84
85
# File 'lib/telerivet/storedfile.rb', line 83

def save()
    super
end

#sha256Object



137
138
139
# File 'lib/telerivet/storedfile.rb', line 137

def sha256
    get('sha256')
end

#sizeObject



113
114
115
# File 'lib/telerivet/storedfile.rb', line 113

def size
    get('size')
end

#sourceObject



129
130
131
# File 'lib/telerivet/storedfile.rb', line 129

def source
    get('source')
end

#thumbnail_urlObject



153
154
155
# File 'lib/telerivet/storedfile.rb', line 153

def thumbnail_url
    get('thumbnail_url')
end

#time_createdObject



141
142
143
# File 'lib/telerivet/storedfile.rb', line 141

def time_created
    get('time_created')
end

#typeObject



109
110
111
# File 'lib/telerivet/storedfile.rb', line 109

def type
    get('type')
end

#urlObject



149
150
151
# File 'lib/telerivet/storedfile.rb', line 149

def url
    get('url')
end

#user_idObject



145
146
147
# File 'lib/telerivet/storedfile.rb', line 145

def user_id
    get('user_id')
end