Class Attachment
Handles Service attachments.
Examples
Attachment a;
a.load(2); // Loads attachment with ID = 2
a.setValue("name", "test.txt");
print(a.getValue("size")); // Size in bytes
Constructors
Attachment()
Initializes a new instance of the Attachment class.
Declaration
Attachment Examples
Attachment a;
a.load(2); // Loads attachment with id = 2
a.setValue("name", "test.txt");
print(a.getValue("size")); // Size in bytes
Methods
dump()
Dumps the attachment file to output.
Declaration
Bool dump() Returns
| Type | Description |
| Bool | True if everything is OK; otherwise false. |
dump(Bool)
Dumps the attachment file to output. The optional parameter if true tells the browser to download the file, and not attempt to display it.
Declaration
Bool dump(Bool download) Parameters
| Type | Name | Description |
| Bool | download | True if you want to download the file instead of display it. |
Returns
| Type | Description |
| Bool | True if everything is OK; otherwise false. |
getBase64()
Returns the attachment as base64 encoded string.
Declaration
String getBase64() Returns
| Type | Description |
| String | The attachment as base64 encoded string. |
getDownloadUrl(Bool,Bool)
Constructs a download URL for the attachment.
Declaration
String getDownloadUrl(Bool external, Bool saveToDisk) Parameters
| Type | Name | Description |
| Bool | external | The URL to be used by a customer or an user. |
| Bool | saveToDisk | Is this a link used to hint to the web browser with http headers that the file is not to be opened, but saved to disk? |
Returns
| Type | Description |
| String | The download URL for the attachment. |
getRaw()
Gets the whole attachment as a String without any special encoding.
Declaration
String getRaw() Returns
| Type | Description |
| String | The raw attachment without any special encoding. |
getValue(String)
Gets a value from the attachment class.
Declaration
String getValue(String name) Parameters
| Type | Name | Description |
| String | name | The field to get the value for. |
Returns
| Type | Description |
| String | The value of the property given in name. |
load(Integer)
Loads a Service attachment from disk.
Declaration
Bool load(Integer id) Parameters
| Type | Name | Description |
| Integer | id | Attachment ID. |
Returns
| Type | Description |
| Bool | True if the load was successful; otherwise false. |
remove()
Deletes the attachment record from the database and the attachment file from disk.
Declaration
remove() Returns
| Type | Description |
save()
Saves the attachment to disk.
Declaration
Integer save() Returns
| Type | Description |
| Integer | The attachment ID. |