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.

(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);