aamalig / django-profile

Automatically exported from code.google.com/p/django-profile
BSD 2-Clause "Simplified" License
0 stars 0 forks source link

IOerror: Permission denied #41

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
I always get the error when uploading an avatar

IOError at /profiles/profile/edit/avatar/

[Errno 13] Permission denied:
u'/project-folder/media/avatars/2008/Dec/01/myavatar_.jpg'

Point to line 214.

 207.  form = AvatarForm(request.POST, request.FILES)
 208. if form.is_valid():
 209. image = form.cleaned_data.get('url') or form.cleaned_data.get('photo')
 210. avatar = Avatar(user=request.user, image=image, valid=False)
 211. avatar.image.save("%s.jpg" % request.user.username, image)
 212. image = Image.open(avatar.image.path)
 213. image.thumbnail((480, 480), Image.ANTIALIAS)

 214. image.convert("RGB").save(avatar.image.path, "JPEG") ...

 215. avatar.save()
 216. return HttpResponseRedirect('%scrop/' % request.path_info)
 217.
 218. base, filename = os.path.split(avatar_path)
 219. generic, extension = os.path.splitext(filename)

Original issue reported on code.google.com by neopro...@gmail.com on 1 Dec 2008 at 4:04

GoogleCodeExporter commented 8 years ago
i think you need to change the directory permissions for media. To check this 
you can
insecurely open write access for the whole media directory, then go from there:
  chmod -R a+rw media
(from project root)
you should not get a write error after that.
To secure the media dir better, you should read up on Unix permissions.

Original comment by ericd...@gmail.com on 2 Dec 2008 at 1:10

GoogleCodeExporter commented 8 years ago
I'm sure that it's not unix&permissions related problem, I try all the ways with
permissions (including your way)

Maybe its about PIL libraries, but I dont expect to be answered and resolved in 
a
short time by the PIL team, not so dynamic... and I only have that problem with
django-profile.

I have no problem with admin interface but site throws the errors below

Full tracebak is:
=================
Environment:

Request Method: POST
Request URL: http://127.0.0.1:8000/profiles/profile/edit/avatar/
Django Version: 1.1 pre-alpha SVN-9538
Python Version: 2.5.1
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.sitemaps',
 'django.contrib.flatpages',
 'django.contrib.admin',
 'django.core.paginator',
 'django.contrib.comments',
 'myproject',
 'tagging',
 'userprofile',
 'django.contrib.admindocs']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.middleware.locale.LocaleMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.middleware.doc.XViewMiddleware',
 'pagination.middleware.PaginationMiddleware',
 'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware')

Traceback:
File "/Users/neoprolog/django/django-profile/userprofile/views.py" in 
avatarchoose
  214.             image.convert("RGB").save(avatar.image.path, "JPEG")

File "/Library/Python/2.5/site-packages/PIL/Image.py" in save
  1399.             fp = __builtin__.open(fp, "wb")

Exception Type: IOError at /profiles/profile/edit/avatar/
Exception Value: [Errno 13] Permission denied:
u'/Users/neoprolog/django-projects/myproject/media/userprofile/avatars/2008/Dec/
02/avatar_.jpg'

Original comment by neopro...@gmail.com on 2 Dec 2008 at 6:50

GoogleCodeExporter commented 8 years ago
Okey, thats not an issue, so I'll post to mailing list,
thanks :P

Original comment by neopro...@gmail.com on 2 Dec 2008 at 7:03

GoogleCodeExporter commented 8 years ago
in settings,
I18N_URLS = False
resolves the problem :-)

Original comment by neopro...@gmail.com on 2 Dec 2008 at 7:16