# Filesystem

> Configure file storage for a self-hosted Advanzo CRM: the local filesystem or an Amazon S3 bucket for uploads and email attachments.

Advanzo CRM uses the local file system. All files uploaded through the Advanzo CRM dashboard, including the attachments of imported emails, are stored on the server on which Advanzo CRM is installed.

If you handle a lot of files and most of your emails contain attachments, you can configure an **Amazon S3** bucket instead. The files are then saved in the Amazon S3 bucket and not on your server.

> **Info:** Uploaded files such as logos and avatars are not saved in the bucket. They are still saved on the server on which Advanzo CRM is installed.

## What Is Amazon S3?

Amazon S3 is the "**Simple Storage Service**" provided by Amazon Web Services (AWS). It allows you to store objects through a web service interface. To read more about S3, [click here](https://en.wikipedia.org/wiki/Amazon_S3).

Please keep in mind that AWS S3 is a paid service: you pay for the storage you use, but it is fairly affordable.

## Create an S3 Bucket

- Log in to your [AWS Console](https://console.aws.amazon.com/).
- Make sure that your AWS account is verified by Amazon.
- Click **Services** and under **Storage** choose **S3**.
- Click **Create Bucket**.
- Enter a **Bucket name**, for example your-company-advanzo-bucket.
- Choose a **Region**.
- In the **Object Ownership** configuration section, apply the following settings:

  Object Ownership settings

    - Select **ACLs enabled**.
    - Under Object Ownership, select **Object writer**.
- Scroll down and **uncheck** the **Block all public access** option.

  On this screen

    - Uncheck **Block all public access**.
    - Check the acknowledgment box: "I acknowledge that the current settings might result in this bucket and the objects within becoming public."
- Click **Create Bucket**.

Now you need encryption keys (secrets) to communicate with S3 from your Advanzo CRM installation. For this, AWS provides the IAM service, where you can manage users and encryption keys.

## Create an IAM User

- On the AWS console page, select the IAM service, or [click here](https://console.aws.amazon.com/iam/home).
- In the left sidebar, select **Users** and, on the users page, click **Add User**.

- Enter a user name.
- Click **Next**.
- On the next screen, select **Attach policies directly**.
- A list of policies appears. **Search for S3** and select **AmazonS3FullAccess**.
- Click the **Next** button.

- Click **Create User**.
- After the user is created, you are redirected to the users table. Click the user name in the table.
- Click the **Security Credentials** tab.
- Scroll down to the **Access keys** section.
- Click **Create access key**.
- Choose **Application running outside AWS**.
- Click **Next**.
- Click **Create Access Key**.
- **Download the .csv file** which contains all your credentials (AWS Access Key ID & Secret Key).

## Configure the S3 Bucket

> **Warning:** Once you use the S3 bucket for storage, we do not recommend removing the bucket configuration and going back to local storage, because the files that were uploaded to the bucket will no longer be accessible.

Now that you have created the bucket in AWS, created the IAM user with the proper policy and generated the access keys, you are ready to configure the S3 bucket in Advanzo CRM.

Edit the `.env` file in the root of your Advanzo CRM installation and add the following contents at the bottom of the file:

```none
MEDIA_DISK=s3 AWS_ACCESS_KEY_ID=your-access-key-from-the-csv-file AWS_SECRET_ACCESS_KEY=your-secret-key-from-the-csv-file AWS_DEFAULT_REGION=bucket-region AWS_BUCKET=bucket-name
```

[Read more](https://www.advanzo.ch/docs/sections/config#edit-env-file) about editing the `.env` file.

The **AWS_DEFAULT_REGION** value depends on the region you selected when creating the bucket. The region key is shown on the S3 buckets listing page.

For example, if you selected EU (Frankfurt), the value of AWS_DEFAULT_REGION is eu-central-1. To view the complete list, [click here](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Concepts.RegionsAndAvailabilityZones.html).
