# Special characters in attachment file names

If you want to send attachments with special characters in their file names, you will need to make sure that you encode the file name first, e.g., using `encodeURI()`. Here's an example of a standard outbound Unifi attachment stream script with the correct escaping in place.

```javascript
(function processStageToRequest(request, stage, transaction, message, bond, scratchpad) {

  // This information would normally come from the AttachmentSender
  var sender = new x_snd_eb.AttachmentSender(transaction, bond);
  sender.next();

  var file_name = sender.attachment_name;
  var mime_type = sender.attachment_type;
  var attach_id = sender.attachment_id;


  //-----------------------
  // Path construction
  //-----------------------
  scratchpad.file_name = encodeURI(file_name);
  scratchpad.reference = stage.external_reference;

  // ?file_name=${scratchpad.file_name}&reference=${scratchpad.reference}

  //-----------------------
  // Headers construction
  //-----------------------

  // Compose the scratchpad headers and payload
  scratchpad.headers = {
    "Content-Type": mime_type
  };

  //-----------------------
  // Payload construction
  //-----------------------

  // This is the string that triggers attachment streaming outbound
  payload = 'sys_attachment:' + attach_id;

})(request, stage, transaction, message, bond, scratchpad);
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.sharelogic.com/unifi/3.1/troubleshooting/attachments/special-characters-in-attachment-file-names.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
