# File storage

# Local file system

If you would like to store file uploads on the same server that Outline is running from then you can do so using the local file system storage option.

## Environment Variables

Set the following environment variables.

```bash
FILE_STORAGE=local
FILE_STORAGE_UPLOAD_MAX_SIZE=26214400
FILE_STORAGE_IMPORT_MAX_SIZE=
FILE_STORAGE_WORKSPACE_IMPORT_MAX_SIZE=
```


When running in docker, files are stored inside the container by default (at `/var/lib/outline/data`), in order for files to be persisted to the host file system a mapping needs to exist in the `docker-compose.yml`. You will find that the configuration is very similar to Postgres, the following two options are available – docker volumes are preferred for simplicity and portability:

## Docker Volume

To store the files in a [docker volume](https://docs.docker.com/storage/volumes/) use the following mapping style:

```javascript
    volumes:
      - storage-data:/var/lib/outline/data
```

## File system folder

To store the files in a location on your local file system using a [bind mount](https://docs.docker.com/storage/bind-mounts/). This is particularly useful when migrating from previously using Minio, as you can point the app at where the files were previously stored and everything will continue to work.

```javascript
    volumes:
      - /location/on/host/filesystem:/var/lib/outline/data
```


If you get permissions errors writing files, ensure that Outline has permission to write to the directory, by giving the user ID access: `chown 1001 /location/on/host/filesystem`


# AWS S3

This guide assumes that you’ve created a bucket in Amazon S3 region `us-east-2` called `my-bucket-name` . If your bucket is named differently or in another region update the values appropriately. Since September 2020 all new buckets in S3 must be accessed via the “VirtualHost” method where the bucket and region are contained within the hostname, the config below reflects this change.

## Environment Variables

```bash
FILE_STORAGE=s3
AWS_REGION=us-east-2
AWS_S3_FORCE_PATH_STYLE=false
AWS_S3_UPLOAD_BUCKET_NAME=my-bucket-name
AWS_S3_UPLOAD_BUCKET_URL=https://my-bucket-name.s3.us-east-2.amazonaws.com
AWS_S3_UPLOAD_MAX_SIZE=26214400
AWS_ACCESS_KEY_ID=AK66L9HZpTtfrpFFgtVxcxOUTn
AWS_SECRET_ACCESS_KEY=97L9HfssZpTtfrxOUTVxcnpgtSa
```

## Permissions

Ensure that “Block public access” (`BlockPublicAcls`) is set to “off” at the bucket level.

### Cross-origin resource sharing (CORS)

Under your bucket permissions add the following policy json and update the AllowedOrigins to match your installation url.


```json
[
    {
        "AllowedHeaders": [
            "*"
        ],
        "AllowedMethods": [
            "PUT",
            "POST"
        ],
        "AllowedOrigins": [
            "https://docs.mycompany.com"
        ],
        "ExposeHeaders": []
    },
    {
        "AllowedHeaders": [],
        "AllowedMethods": [
            "GET"
        ],
        "AllowedOrigins": [
            "*"
        ],
        "ExposeHeaders": []
    }
]
```


### IAM Policy

The following actions must to be allowed, It is recommended to create an IAM user with only this policy attached but you may add to another user, then generate an access key and secret for the user to be included in the environment variables.


```json
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "ObjectActions",
            "Effect": "Allow",
            "Action": [
                "s3:GetObjectAcl",
                "s3:DeleteObject",
                "s3:PutObject",
                "s3:GetObject",
                "s3:PutObjectAcl"
            ],
            "Resource": "arn:aws:s3:::my-bucket-name/*"
        },
        {
            "Sid": "ListBucket",
            "Effect": "Allow",
            "Action": "s3:ListBucket",
            "Resource": "arn:aws:s3:::my-bucket-name"
        }
    ]
}
```


## Transfer Acceleration


:::info
**Note:** This configuration is only available from v0.63.0 onwards

:::


S3 offers “[transfer acceleration](https://docs.aws.amazon.com/AmazonS3/latest/userguide/transfer-acceleration.html)” as an optional feature which takes advantage of Cloudfront’s CDN to improve performance of uploads and downloads. If enabled for your bucket enter the url provided by AWS in the `AWS_S3_ACCELERATE_URL` environment variable.


# S3-compatible services

Outline can be used with the vast majority of S3-compatible API’s as a very small subset of the available API interface is used, the following have been tested by members of the community.

| Service | Compatible |
|---------|------------|
| Amazon S3 | ✅          |
| Minio   | ✅          |
| DigitalOcean Object Storage | ✅          |
| Alibaba Cloud / Aliyun OSS | ✅ ([discussion](https://github.com/outline/outline/discussions/4955)) |
| Scaleway | ✅ ([discussion](https://github.com/outline/outline/discussions/2666#discussioncomment-6781502)) |
| OVH Object Storage | ✅ ([discussion](https://github.com/outline/outline/discussions/2666#discussioncomment-18001290)) |
| Cloudflare R2 | ❌ ([discussion](https://github.com/outline/outline/discussions/4480#discussioncomment-5449856)) |
| Backblaze | ❌ ([discussion](https://github.com/outline/outline/discussions/2666#discussioncomment-3421528)) |

---

**Documents**

- [License restrictions](https://docs.getoutline.com/s/hosting/doc/license-restrictions-f9aq6uEL3H)
- [Requirements](https://docs.getoutline.com/s/hosting/doc/requirements-ULdYnwi4wG)
- [Installation methods](https://docs.getoutline.com/s/hosting/doc/installation-methods-pSvgz9j0QC)
- [Configuration](https://docs.getoutline.com/s/hosting/doc/configuration-509J4lAzjo)
- [Business + Enterprise](https://docs.getoutline.com/s/hosting/doc/business-enterprise-rv0715NxO3)
- [Backups](https://docs.getoutline.com/s/hosting/doc/backups-KZtPOADCHG)
- [Troubleshooting](https://docs.getoutline.com/s/hosting/doc/troubleshooting-HXckrzCqDJ)