
By Alex Gavard
A custom FTP provider for Strapi 5, automatically organizing media files into year and month folders.
released May 1, 2025
npm install strapi5-provider-upload-ftpThis is a Strapi 5 provider plugin that allows you to upload media files via FTP. For better organization, it will automatically create year and month folders inside your FTP server.
Uploads media files to an FTP server.
Automatically creates year and month directories for file organization:
Allows you to set a custom path for organizing files on your FTP server (optional).
images.yourwebsite.com) to serve media, enhancing your branding and control.To install this plugin in your Strapi project, run the following command:
npm install strapi5-provider-upload-ftp --saveAfter installing the plugin, you need to configure it in the config/plugins.js file. If this file doesn't already exist, create it. This file should contain the following information:
module.exports = ({ env }) => ({
upload: {
config: {
provider: 'strapi5-provider-upload-ftp',
providerOptions: {
host: env('FTP_HOST'),
port: env.int('FTP_PORT', 21),
user: env('FTP_USER'),
password: env('FTP_PASSWORD'),
publicUrl: env('FTP_PUBLIC_URL'),
ftp_custom_path: env('FTP_CUSTOM_PATH', ''),
secure: env.bool('FTP_SECURE', false),
passive: env.bool('FTP_PASSIVE', true),
},
},
},
});Because of Strapi's default security settings, you need to change the contentSecurityPolicy configuration to properly view thumbnails in the Media Library. Instead of using the strapi::security setting, replace it with the object below, as described in the middleware configuration.
export default [
'strapi::logger',
'strapi::errors',
{
name: 'strapi::security',
config: {
contentSecurityPolicy: {
useDefaults: true,
directives: {
'connect-src': ["'self'", 'https:'],
'img-src': [
"'self'",
'data:',
'blob:',
'yourwebsite.com',
],
'media-src': [
"'self'",
'data:',
'blob:',
'yourwebsite.com',
],
upgradeInsecureRequests: null,
},
},
},
},
'strapi::cors',
'strapi::poweredBy',
'strapi::query',
'strapi::body',
'strapi::session',
'strapi::favicon',
'strapi::public',
];You will also need to create a .env file with the following information (replace the values with your own FTP credentials):
FTP_HOST=ftp.yourserver.com
FTP_PORT=21
FTP_USER=your-ftp-username
FTP_PASSWORD=your-ftp-password
FTP_PUBLIC_URL=https://yourwebsite.com
FTP_CUSTOM_PATH=uploads/images # Optional: Set a custom folder path
FTP_SECURE=false # Set to true if you want to use FTPS (FTP over SSL/TLS)
FTP_PASSIVE=true # Use passive mode (recommended for most firewalls)The plugin has been tested and works with Strapi v5.4.1 and Node.js v20.15.1.
Share your work with the community and get it listed in the Strapi ecosystem for everyone to discover and use.
Submit
