> ## Documentation Index
> Fetch the complete documentation index at: https://docs.superoffice.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Attachment

> Handles Service attachments.

Handles Service attachments.

## Constructors

### Attachment()

```crmscript theme={null}
Attachment
```

Initializes a new instance of the Attachment class.

## Methods

## dump()

Dumps the attachment file to output.

```crmscript theme={null}
Bool dump()
```

**Returns:** [CRMScript.Global.Bool](CRMScript.Global.Bool) - True if everything is OK; otherwise false.

<Note>
  Use dump(Bool) to signal the browser to download the file instead of display it.
</Note>

## 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.

```crmscript theme={null}
Bool dump(Bool download)
```

**Returns:** [CRMScript.Global.Bool](CRMScript.Global.Bool) - True if everything is OK; otherwise false.

## getBase64()

Returns the attachment as base64 encoded string.

```crmscript theme={null}
String getBase64()
```

**Returns:** [CRMScript.Global.String](CRMScript.Global.String) - The attachment as base64 encoded string.

<Note>
  This can be used to load a binary attachment into a string, as base64 coded data is valid ASCII.
</Note>

## getDownloadUrl(Bool,Bool)

Constructs a download URL for the attachment.

```crmscript theme={null}
String getDownloadUrl(Bool external, Bool saveToDisk)
```

**Returns:** [CRMScript.Global.String](CRMScript.Global.String) - The download URL for the attachment.

<Note>
  There are 2 kinds of URLs: external = used by customers; internal = used by Service users.
</Note>

## getRaw()

Gets the whole attachment as a String without any special encoding.

```crmscript theme={null}
String getRaw()
```

**Returns:** [CRMScript.Global.String](CRMScript.Global.String) - The raw attachment without any special encoding.

## getValue(String)

Gets a value from the attachment class.

```crmscript theme={null}
String getValue(String name)
```

**Returns:** [CRMScript.Global.String](CRMScript.Global.String) - The value of the property given in name.

<Note>
  The current implementation supports the following values as the name parameter.

  * id: the attachment ID
  * contentType: content descriptor
  * name: the filename
  * size: size in bytes
  * key: authentication key
  * charset
  * dbiAgentId
  * dbiKey
  * dbiLastModified
  * dbiLastSyncronized
</Note>

## load(Integer)

Loads a Service attachment from disk.

```crmscript theme={null}
Bool load(Integer id)
```

**Returns:** [CRMScript.Global.Bool](CRMScript.Global.Bool) - True if the load was successful; otherwise false.

## remove()

Deletes the attachment record from the database and the attachment file from disk.

```crmscript theme={null}
remove()
```

**Returns:** [CRMScript.Global.Void](CRMScript.Global.Void)

## save()

Saves the attachment to disk.

```crmscript theme={null}
Integer save()
```

**Returns:** [CRMScript.Global.Integer](CRMScript.Global.Integer) - The attachment ID.

## saveBase64(String)

Creates a filename and saves a base64-coded attachment to disk.

```crmscript theme={null}
Integer saveBase64(String attachment)
```

**Returns:** [CRMScript.Global.Integer](CRMScript.Global.Integer) - The actual number of bytes written to disk.

## setValue(String,String)

Sets a value on the attachment object.

```crmscript theme={null}
Void SetValue(String name, String value)
```

**Returns:** [CRMScript.Global.Void](CRMScript.Global.Void)

<Note>
  The current implementation supports the following values as the name parameter.

  * id: the attachment ID
  * contentType: content descriptor
  * name: the filename
  * size: size in bytes
  * key: authentication key
  * charset
  * dbiAgentId
  * dbiKey
  * dbiLastModified
  * dbiLastSyncronized
</Note>


## Related topics

- [attachment](/en/api/mdo-providers/reference/attachment.md)
- [Attachment location](/en/onsite/config/service/attachment-location.md)
- [Archive attachments](/integrations/mail-link/archive-attachment.md)
- [attachment table](/en/database/tables/attachment.md)
- [Validate Attachments](/en/api/reference/restful/agent/ticket_agent/validate-attachments.md)
- [Add Attachments](/en/api/reference/restful/agent/ticket_agent/add-attachments.md)
