# Local File Storage

When locally deploying the Form.io Platform, an S3 compatible storage solution is the preferred method for local file storage. [SeaweedFS](https://github.com/seaweedfs/seaweedfs) is an open-source distributed object storage server written in Go, designed for Private Cloud infrastructure providing AWS S3 storage functionality. This server is best suited for storing unstructured data and files such as photos and videos within the *local environment.*&#x20;

SeaweedFS can be used on an Enterprise level, however many customers opt to use storage provided by an existing component of their technology stack, or other storage methods when deploying to the Cloud or their own On-Premise environment.&#x20;

## Installing SeaweedFS

{% hint style="info" %}
If the Form.io Platform was deployed to the environment with the [**docker-compose**](https://help.form.io/deployments/deployment-guide/local-deployment) methodology, SeaweedFS is already included in the deployment, and manual installation is not required.&#x20;
{% endhint %}

### Pre-Requisites

To deploy a new SeaweedFS server, complete the following pre-requisite steps:

1. Install [**Docker**](https://docker.io/) either on the local machine, or on a private cloud server.
2. Create the necessary directories to store files using the file browser, or by executing the following commands:

   ```
   mkdir ~/seaweedfs/data
   ```
3. Run the following command to pull the SeaweedFS container from Docker Hub:

   ```
   docker pull chrislusf/seaweedfs
   ```

### **Deploying the SeaweedFS Container**

1. Execute the following command to start the SeaweedFS container:

```bash
docker run -itd \
  -e "AWS_ACCESS_KEY_ID=CHANGEME" \
  -e "AWS_SECRET_ACCESS_KEY=CHANGEME" \
  --name formio-seaweedfs \
  --restart unless-stopped \
  -p 8333:8333 \
  -p 23646:23646 \
  -v ~/seaweedfs/data:/data \
  chrislusf/seaweedfs server -s3
```

{% hint style="warning" %}
Note that the sample credentials "CHANGEME" should be updated to reflect the credentials intended for access to the file storage.
{% endhint %}

In this example, note that SeadweedFS is mounting the folder `~/seaweedfs`. This can be changed to any drive on the system machine where SeaweedFS should store files.

2. Verify the formio-seaweedfs container is running by executing the following command:

```
docker ps
```

The result should look similar to the following:

![](https://3305536326-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MPHoF2HwOA0s5HV_AIB%2Fuploads%2FnfYwEvXfeAUT7kvoqBCr%2Fseaweed-docker.PNG?alt=media\&token=490287c9-7d0d-4d30-bf33-0b94d8cb9eaa)

3. Modify the `hosts` file to allow easy access to SeaweedFS:
   * **On MacOS/Linux:** From the terminal run the following command, logging in if prompted:

<pre><code><strong>sudo nano /etc/hosts
</strong></code></pre>

* **On Windows:** Use Notepad as an Administrator to open the file `C:\Windows\System32\Drivers\etc\hosts`\
  \
  Once the file is open, modify the appropriate line to read:

```
127.0.0.1       localhost seaweedfs Save the file and exit the text editor.
```

4. Start the admin portal with the command:

```
docker exec -it local-seaweedfs-1 /usr/bin/weed admin
```

5. In a browser, navigate to [http://seaweedfs:23646/](http://minio:9001/) ( or <http://localhost:23646>)  to view the SeaweedFS interface.
6. After successfully loading the SeaweedFS dashboard, navigate to **Buckets** under the Object Store tools on the left-hand menu.

<figure><img src="https://3305536326-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MPHoF2HwOA0s5HV_AIB%2Fuploads%2F4m5JHqagoHdjX3YTlxTr%2Fseaweed-admin-portal.PNG?alt=media&#x26;token=0337e0f7-faef-4b48-9241-8b1572ea36bf" alt=""><figcaption></figcaption></figure>

7. Create a new Bucket by clicking on the +**Create Bucket** button. Give the bucket a descriptive name and record the choice for future configurations.

The SeaweedFS Server should now be operational.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://help.form.io/deployments/deployment-guide/local-deployment/local-file-storage.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
