Class: Telerivet::StoredFile
- 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
- #category ⇒ Object
-
#delete ⇒ Object
Deletes this stored file.
- #description ⇒ Object
- #description=(value) ⇒ Object
- #filename ⇒ Object
- #filename=(value) ⇒ Object
- #get_base_api_path ⇒ Object
- #id ⇒ Object
- #message_id ⇒ Object
- #project_id ⇒ Object
-
#save ⇒ Object
Saves any fields that have changed for this stored file.
- #sha256 ⇒ Object
- #size ⇒ Object
- #source ⇒ Object
- #thumbnail_url ⇒ Object
- #time_created ⇒ Object
- #type ⇒ Object
- #url ⇒ Object
- #user_id ⇒ Object
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
#category ⇒ Object
125 126 127 |
# File 'lib/telerivet/storedfile.rb', line 125 def category get('category') end |
#delete ⇒ Object
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 |
#description ⇒ Object
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 |
#filename ⇒ Object
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_path ⇒ Object
161 162 163 |
# File 'lib/telerivet/storedfile.rb', line 161 def get_base_api_path() "/projects/#{get('project_id')}/files/#{get('id')}" end |
#id ⇒ Object
97 98 99 |
# File 'lib/telerivet/storedfile.rb', line 97 def id get('id') end |
#message_id ⇒ Object
133 134 135 |
# File 'lib/telerivet/storedfile.rb', line 133 def get('message_id') end |
#project_id ⇒ Object
157 158 159 |
# File 'lib/telerivet/storedfile.rb', line 157 def project_id get('project_id') end |
#save ⇒ Object
Saves any fields that have changed for this stored file.
83 84 85 |
# File 'lib/telerivet/storedfile.rb', line 83 def save() super end |
#sha256 ⇒ Object
137 138 139 |
# File 'lib/telerivet/storedfile.rb', line 137 def sha256 get('sha256') end |
#size ⇒ Object
113 114 115 |
# File 'lib/telerivet/storedfile.rb', line 113 def size get('size') end |
#source ⇒ Object
129 130 131 |
# File 'lib/telerivet/storedfile.rb', line 129 def source get('source') end |
#thumbnail_url ⇒ Object
153 154 155 |
# File 'lib/telerivet/storedfile.rb', line 153 def thumbnail_url get('thumbnail_url') end |
#time_created ⇒ Object
141 142 143 |
# File 'lib/telerivet/storedfile.rb', line 141 def time_created get('time_created') end |
#type ⇒ Object
109 110 111 |
# File 'lib/telerivet/storedfile.rb', line 109 def type get('type') end |
#url ⇒ Object
149 150 151 |
# File 'lib/telerivet/storedfile.rb', line 149 def url get('url') end |
#user_id ⇒ Object
145 146 147 |
# File 'lib/telerivet/storedfile.rb', line 145 def user_id get('user_id') end |