To use SFTP as your storage driver, you need to have an SFTP server set up and running. Many cloud hosting providers offer SFTP access to their storage services.
To enable SFTP storage support in Koel, you need to provide the following configuration in your `.env` file:
```
STORAGE_DRIVER=sftp
SFTP_HOST=
SFTP_PORT=
# The absolute path of the directory to store the media files on the SFTP server.
# Make sure the directory exists and is writable by the SFTP user.
SFTP_ROOT=
# You can use either a username/password pair…
SFTP_USERNAME=
SFTP_PASSWORD=
# …or private key authentication:
SFTP_PRIVATE_KEY=
SFTP_PASSPHRASE=
```
After reloading, Koel will start using SFTP as its storage driver. You can now upload your music files to your SFTP server directly from Koel’s web interface.
Since Amazon S3 and S3-compatible services share the same API, you can use the same configuration (`AWS_*`) for both.
Koel has been tested with Amazon S3, [DigitalOcean Spaces](https://www.digitalocean.com/products/spaces), and [Cloudflare R2](https://www.cloudflare.com/developer-platform/r2/), but it should work with any S3-compatible service given the right configuration.
### Amazon S3
Create a new S3 bucket and obtain your access key ID and secret key from the AWS console. Then, populate these values in your `.env` file:
```
STORAGE_DRIVER=s3
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_REGION=
AWS_ENDPOINT=
AWS_BUCKET=
```
After reloading, Koel will start using S3 as its storage. You can now upload your music files to your S3 bucket directly from Koel’s web interface.
In order to use S3 for streaming, you'll also need to set up a cross-origin resource sharing (CORS) configuration for your bucket by going to the Permissions tab. Here's a sample policy that allows streaming from any origin:
```json
[
{
"AllowedHeaders": [],
"AllowedMethods": [
"GET"
],
"AllowedOrigins": [
"*"
],
"ExposeHeaders": []
}
]
```
### DigitalOcean Spaces
To use [DigitalOcean Spaces](https://www.digitalocean.com/products/spaces), you can follow the same steps as with Amazon S3. Below are some screenshots to help you get started.
<CaptionedImage:src="doCreateBucket"alt="Create DO Spaces bucket screen">Create a DigitalOcean Spaces bucket</CaptionedImage>
<CaptionedImage:src="doBucketSettings"alt="DO Spaces bucket settings">DigitalOcean Spaces bucket settings with CORS Configurations</CaptionedImage>
The access key ID and secret key can be generated and obtained via the API -> Space Keys tab in the DigitalOcean control panel:
Koel Plus also supports using Dropbox as a storage driver, although the setup is a bit different.
1. First, [create a new Dropbox app](https://www.dropbox.com/developers/apps/create) with the "App folder" access type and set up sufficient permissions to read and write files.
<CaptionedImage:src="dropboxCreateApp"alt="Create a Dropbox app">Create a Dropbox app</CaptionedImage>
2. Under your Dropbox app's Settings tab, make a note of the "App key" and "App secret" values. Now, from the root folder of your Koel installation, run the following command:
4. Enter the access code back into the command line's prompt. Koel will then finalize the setup automatically and start using Dropbox as its storage.
Now when you upload music files to Koel, they'll be stored in your Dropbox app's folder.
:::warning Two-way sync not supported
Koel does not support two-way sync with Dropbox — at least not yet. This means manual changes made to your Dropbox folder will not be reflected in Koel.
:::
<scriptlang="ts"setup>
import doCreateBucket from '../assets/img/plus/storage/do-create-bucket.webp'
import doBucketSettings from '../assets/img/plus/storage/do-bucket-settings.webp'
import r2CreateBucket from '../assets/img/plus/storage/r2-create-bucket.webp'
import r2BucketSettings from '../assets/img/plus/storage/r2-bucket-settings.webp'
import dropboxCreateApp from '../assets/img/plus/storage/dropbox-create-app.webp'
import dropboxAppSettings from '../assets/img/plus/storage/dropbox-app-permissions.webp'