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

# Workflow attachments

> How to manage file attachments in Atoti Sign-Off workflow actions, including default storage behavior, changing the folder location, and customizing the file storage mechanism.

## Overview

The default workflows in Atoti Sign-Off contain user tasks that let users
save files at every point in the workflow. This includes when users:

* publish or archive definitions
* request approval for tasks
* approve or reject tasks

## Default behavior

By default, when a user saves an attachment, the files are saved in the system where
Atoti Sign-Off is deployed, relative to the location of the executable starter jar. This is based on
the value of the `sign-off.workflow.file-storage-path` property, which defaults to `sign-off/workflow/attachments`.

<Warning>
  This path is used when both saving and retrieving files. Should you ever update the property value
  **after** you have saved files, you will need to move the files from the old location to the new one.
</Warning>

Then, if a user saves a file in a workflow action, Atoti Sign-Off will:

1. Check if the folder specified by `sign-off.workflow.file-storage-path` exists.
2. If not, Atoti Sign-Off will create the folder.
3. Atoti Sign-Off will save the file under a timestamped folder, to prevent unintended overwrites.
4. The path of the file will be saved as a workflow variable for future retrieval.

Then, when a user attempts to access the attachment via the audit trail of the workflow, they will be
able to load the file via the path variable.

## Change the folder location

If you want to change the folder location, modify the value of the `sign-off.workflow.file-storage-path`
property. This value can be absolute or relative.

## Customize the save mechanism

If you want to customize the save mechanism, add your own implementation
of `IWorkflowFileStorageService` and [expose it as a Spring Bean](..#importing-spring-beans-into-the-project).

<Accordion title="IWorkflowFileStorageService">
  ```java theme={"languages":{"custom":["/engine/python-sdk/0.9/languages/pycon.tmLanguage.json"]}}
  /**
   * <b>IWorkflowFileStorageService</b>
   *
   * <p>Handles file storage when saving attachments in the workflow.
   *
   * @author ActiveViam
   */
  public interface IWorkflowFileStorageService {
      /**
       * Saves a file to the storage.
       *
       * @param file the file to upload
       * @return the file name and parent folder, which is a random UUID
       */
      String saveFile(MultipartFile file);

      /**
       * Gets a file from the storage.
       *
       * @param fileNameAndParentFolder the file name and parent folder, which is a random UUID
       * @return the downloaded file
       */
      Resource getFile(String fileNameAndParentFolder);

      /**
       * Deletes a file from the storage.
       *
       * @param fileNameAndParentFolder the file name and parent folder, which is a random UUID
       */
      void deleteFile(String fileNameAndParentFolder);
  }
  ```
</Accordion>

## FAQ

<AccordionGroup>
  <Accordion title="What should I do if Atoti Sign-Off says my file is too large?">
    Large files can cause performance degradations on your server. To help prevent this, we impose that:

    * Your file must not be larger than the value of the `spring.servlet.multipart.max-file-size`
      property, which defaults to `1MB`.
    * Your request must not be larger than the value of the `spring.servlet.multipart.max-request-size`
      property, which defaults to `10MB`.

    These are [Spring properties](https://docs.spring.io/spring-boot/appendix/application-properties/index.html#appendix.application-properties.web)
    that you can set in your [`application.yml`](../../../user-ref/properties/property-files/application-yml).
  </Accordion>

  <Accordion title="Why do I not have access to the attachment?">
    You may not have access to the folder where the attachments are saved. If so, please contact your
    system administrator.
  </Accordion>
</AccordionGroup>
