Hello!

I'm trying to implement uploading user's avatar. I've tried to follow the 
image blog example from the book and some of the posts related to this 
issue in this forum and I'm still a bit confused and I don't know if I 
could do certain things or how to do them.

What I would like to achieve is this:

-Upload the avatar and store it in the file system. The link to the file 
will be stored in the database. As far as I know this is possible with 
Field('avatar', 'upload'). 
But, my first doubt: could I store the image file with a custom name, for 
example <auth_user.username>.jpg? I see that the file has a strange name 
when it's stored.

-I would like the image to be public, anyone could see that image in any 
browser through its link.
But, my second doubt: the content of the avatar field in my database is a 
File, and when I go to that link I see the content of the file in the URL 
and don't see the image.

Finally, my last doubt, in my web service I access the image data through 
request.post_vars. If I print this data I get something like this:
<Storage {'upload_field': FieldStorage('upload_field', 'myphoto_1.jpg', 
'\xff\xd8\ 
... ... ...\x04\xd9')}>
I guess I have to store the image in the database with this:
row.update(avatar=request.post_vars['upload_field'])
Am I right?


Thank you very much!



-- 



Reply via email to