Reputation: 203
So i have Angular
+ Django REST API
applications hosted on nginx
+ gunicorn
setup.
I'm facing a weird problem . I have my media folder permisssions set to 777
and in my nginx config:
location /media {
alias /home/shalin95/zona_project/zona_api/media;
expires 20m;
}
I have a model Product
with main_picture
field ( ImageField
saving the files to /media/photos/
) .
When i create new instance ( new product ), and sometimes when i want to open the image in the browser i get 403 Forbidden
error.
NOTE: This happens occasionally , not on every instance saved ( no specific pattern , just randomly)
Thank if i go and chmod -R 777
the media folder everything is okay ( i can see the picture ) , but why this happens ( on some occasions ) ?
Upvotes: 1
Views: 1014
Reputation: 203
So i've concluded that this issue only occurs only when the request was larger than ( ~ 4MB ) i think , so i've added
FILE_UPLOAD_MAX_MEMORY_SIZE = 100000000
FILE_UPLOAD_PERMISSIONS = 0o644
in the settings.py
file and now the uploads work okay.
Upvotes: 2