Hello there!
I wrote a SQL sentence to update the media URL inside the database (MySQL in my case).
- Move the images to a new bucket
- Configure Strapi to upload on the new bucket
- Use SQL queries to modify the
urlandformatscolumns in theupload_filetable
Update url column.
UPDATE files
SET url = CONCAT('<YourBucketURL>', url);
Update formats column with image sizes.
UPDATE files
SET formats = JSON_SET(formats, '$.large.url', CONCAT('<YourBucketURL>', JSON_UNQUOTE(JSON_EXTRACT(formats, '$.large.url')))),
formats = JSON_SET(formats, '$.small.url', CONCAT('<YourBucketURL>', JSON_UNQUOTE(JSON_EXTRACT(formats, '$.small.url')))),
formats = JSON_SET(formats, '$.medium.url', CONCAT('<YourBucketURL>', JSON_UNQUOTE(JSON_EXTRACT(formats, '$.medium.url')))),
formats = JSON_SET(formats, '$.thumbnail.url', CONCAT('<YourBucketURL>', JSON_UNQUOTE(JSON_EXTRACT(formats, '$.thumbnail.url'))))
WHERE formats IS NOT NULL;
Hope it helps! 