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

# Configure workflow attachments

> How to configure workflow file attachment storage in Atoti Limits, including the default file storage path, changing the folder location, and customizing the save mechanism via IWorkflowFileStorageService

## Overview

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

* approve limits
* reject limits
* review breaches
* comment on warnings

## Default behavior

By default, when a user saves an attachment, the files are saved in the system where
Atoti Limits is deployed, relative to the location of the executable starter jar. This is based on
the value of the `activeviam.apps.workflow-service.settings.file-storage-path` property, which defaults to `./limits/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 Limits will:

1. Check if the folder specified by `activeviam.apps.workflow-service.settings.file-storage-path` exists.
2. If not, Atoti Limits will create the folder.
3. Atoti Limits 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 `activeviam.apps.workflow-service.settings.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 path of the uploaded file
     */
    String saveFile(MultipartFile file);

    /**
     * Gets a file from the storage.
     *
     * @param path the path of the file to download
     * @return the downloaded file
     */
    Resource getFile(String path);

    /**
     * Deletes a file from the storage.
     *
     * @param path the path of the file to delete
     */
    void deleteFile(String path);
  }
  ```
</Accordion>

## Save files remotely

To save files to a remote drive location rather than a machine-specific location, for
example, a Google Drive or Microsoft Sharepoint, we recommend you use the Attachment Link feature
rather than the Attachment feature. This will give you more control over your files.

To do so, you should:

1. Save the file to your remote drive.
2. Save the attachment link in your workflow.

## FAQ

<AccordionGroup>
  <Accordion title="What should I do if Atoti Limits 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>
