I'm using python Django framework for server and AWS-S3 for store uploaded image. Also, i'm using django-storages library for handle S3. But sometimes images were deleted by itself not through django server. Image urls were still exist in DB. So i changed create, put, delete, get action to get in bucket policy But still deleted by itself.
django-storages setting in settings.py is this
AWS_SECRET_ACCESS_KEY = S3['secret_key']
AWS_REGION = 'ap-northeast-2'
AWS_STORAGE_BUCKET_NAME = 'loopusimage'
AWS_S3_CUSTOM_DOMAIN = '%s.s3.%s.amazonaws.com' % (
AWS_STORAGE_BUCKET_NAME, AWS_REGION)
AWS_DEFAULT_ACL = None
DATA_UPLOAD_MAX_MEMORY_SIZE = 1024000000
FILE_UPLOAD_MAX_MEMORY_SIZE = 1024000000
DEFAULT_FILE_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage
and changed bucket policy is this
"Version": "2012-10-17",
"Statement": [
{
"Sid": "Statement1",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::loopusimage/*"
}
]
}
What should i do to solve my problem?
AWS itself will never delete items in the S3 but there are some scenarios that can be applicable to your problem.
To find your exact problem, you can use AWS CloudTrail. This service will help you to see who(or what) has deleted these images from your bucket. You can check this doc for instruction.