Migrate Existing Files to S3
After configuring the UnoPim AWS Integration, you can move your existing media files from local storage to Amazon S3.
This is useful when:
- the module was installed after media already existed in UnoPim,
- you want old files and new files to be stored in the same S3 bucket,
- you want to reduce dependency on local server storage.
Before You Start
Make sure the following steps are already completed:
- Create an S3 bucket in your AWS account.
- Generate the Access Key ID and Secret Key from IAM.
- Configure your AWS credentials in UnoPim.
If you have not completed these steps yet, follow:
Migrate Existing Media to AWS S3
To move existing UnoPim media files to Amazon S3, run:
php artisan aws_integration:move_existing_filesThis command uploads the existing media from local storage to your configured S3 bucket.
NOTE
Run this command only after your AWS configuration has been saved correctly in UnoPim.
Remove Local Media After Migration
After confirming that the files are successfully available in Amazon S3, you can remove the local copies by running:
php artisan aws_integration:remove_media_filesThis helps free up storage space on your server after migration.
CAUTION
Before removing local files, make sure your migration is complete and the files are accessible from S3.
Update S3 File Visibility (ACL)
You can also update the visibility of files already stored in your S3 bucket.
This command lets you make files:
publicso they can be accessed publicly,privateso access remains restricted.
Run:
php artisan aws_integration:update_visibilityAvailable Options
You can use the following options with the visibility command:
| Option | Description |
|---|---|
--visibility=public or private | Overrides the default visibility stored in the database. |
--path=folder/path | Applies the visibility update only to a specific folder or prefix. |
--dry-run | Shows what would change without actually updating any files. |
Command Examples
Make all matching files public:
php artisan aws_integration:update_visibility --visibility=publicMake files inside a specific folder private:
php artisan aws_integration:update_visibility --path=products --visibility=privatePreview the changes without applying them:
php artisan aws_integration:update_visibility --dry-runRecommended Usage
Before running the visibility update in production:
- use
--dry-runfirst, - check that the selected path is correct,
- confirm whether files should be
publicorprivate.
CAUTION
The visibility update command can affect all matching files in your S3 bucket. Always review the result with --dry-run before applying changes in production.