In MagicAI, you can host your images on Amazon Web Services instead of hosting them on your local server.
Setting up AWS S3
- Go to aws.amazon.com
- If you have an AWS account, log in to your account.
If you don’t have an account, you can get help from this article to create one. - Create an IAM user on AWS with full access to Amazon S3.
Check out this article if you don’t know how. - Create an S3 bucket. Check out this article if you don’t know how.
- Make sure you allow public access.
(Do not select “Block all public access” option.) - Apply the required policy and CORS configurations as described below.
- Bucket Policy configuration
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": "*",
"Action": "s3:*",
"Resource": "arn:aws:s3:::magicai-image/*"
}
]
}
- CORS configuration
[
{
"AllowedHeaders": [
"*"
],
"AllowedMethods": [
"POST",
"GET",
"PUT",
"DELETE",
"HEAD"
],
"AllowedOrigins": [
"*"
],
"ExposeHeaders": []
}
]
- Bucket Policy configuration
- Make sure you allow public access.
- That’s all, let’s configure MagicAI now.
Configuring MagicAI for AWS S3
- Open your .env file in the root directory of MagicAI with a text editor.
- Add the following values to your .env file and enter your corresponding AWS S3 details.
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=
AWS_BUCKET=
AWS_USE_PATH_STYLE_ENDPOINT=false
AWS_ACCESS_KEY_ID: Public key generated by IAM user.
AWS_SECRET_ACCESS_KEY: Secret key generated by IAM user.
AWS_DEFAULT_REGION: Your region in AWS.
AWS_BUCKET: Your S3 bucket name. - Now just set the default storage to AWS S3 from Settings > Storage page in your MagicAI dashboard.
- That’s all!