Regarding to my second question, I've found the image file stored in my server under applications/myapp/uploads, but its name is not myuser.jpg but auth_user.avatar.8d275a959267dd9b.612e6a7067.jpg.
El lunes, 7 de enero de 2013 00:26:03 UTC+1, Wonton escribió: > > Hello Massimo, > > First of all thank you very much for your help. > I've done what you told me, to be exact: > > file_name = auth.user.username+'.jpg' > print file_name > row.update(avatar=db.auth_user.avatar.store(request.post_vars[ > 'upload_field'],filename=file_name)) > > Running this, it seems that everything went well. > The output is: > myuser.jpg > > In the database I get this: > auth_user.id auth_user.username ... auth_user.avatar > 1 myuser ... *file* > > file is a link pointing to: > > https://192.168.1.131:8000/myapp/appadmin/download/db/auth_user.avatar.a633aec9680b76a0.6d696e6f6d6272652e6a7067.jpg > And the content of the file is ok, is the new avatar updated to the > database. > > But, do you know why the name is not myuser.jpg? I would like to call this > link directly from the mobile, and it seems that the name is generated > "randomly". > And, looking at the URL /donwload/db/..., is the image stored in the > server or in the database? I've tried to find it in my server without > success. > > Thank you very much and kind regards! > > El sábado, 5 de enero de 2013 01:50:00 UTC+1, Massimo Di Pierro escribió: >> >> yes >> >> row.update(avatar=db.tablename.avatar.store(request.post_vars[ >> 'upload_field'],filename='yourname.ext')) >> >> On Friday, 4 January 2013 00:36:31 UTC-6, Wonton wrote: >>> >>> Hello Massimo! >>> >>> I bypass the form.proccess because this is a web service used by an iOS >>> app. I do all frontend stuff in iOS and call this web service from the >>> device. >>> >>> And regarding to change the name of the file, is it possible? >>> >>> kind regards! >>> >>> El viernes, 4 de enero de 2013 04:11:16 UTC+1, Massimo Di Pierro >>> escribió: >>>> >>>> You can do >>>> >>>> row.update(avatar=db.tablename.avatar.store(request.post_vars[ >>>> 'upload_field'])) >>>> >>>> by why bypess form.process()? it does it for you. >>>> >>>> On Thursday, 3 January 2013 15:57:24 UTC-6, Wonton wrote: >>>>> >>>>> 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! >>>>> >>>>> >>>>> >>>>> --