What is your db.UserImageStore model, and what is the code for downloading 
the image?

On Monday, June 18, 2012 7:49:58 AM UTC-4, Sushant Taneja wrote:
>
> Hi,
>
> I am building an app using AppEngine + Web2py
>
> A user's profile image is retrieved from his Facebook profile via the 
> Graph API and stored in database.
> The image is stored and displayed correctly. 
> But whenever I right-click and save the image, the saved file name is just 
> some set unicode characters I guess and not the name from which the image 
> is saved.
>
> *Eg:  *-îÏìÄÊ-¨-¢‚H-¦_â.jpg
>
> How do I correct this file name ? Below is the code which I am using to 
> generate image names:
>
>
> def create_user_pic_fb():
>     """
>         This method fetches the FB profile image of the user and sets it 
> as user profile image
>     """
>
>     from google.appengine.api import urlfetch
>     from random import randint
>
>     user_fb_id = request.args[0]
>     user_profile_image_url = 
> FB_PROFILE_IMAGE_URL.replace('USER_FB_ID',user_fb_id)
>
>     random_str = str(randint(1,99999999))
>     logger.debug(random_str)
>
>     # Get profile image blob from facebook
>     result = urlfetch.fetch(user_profile_image_url)
>     logger.debug("Read profile image")
>     profile_image = result.content
>
>     profile_image_name = 'UserImageStore.profile_image.' + random_str + 
> '_' + user_fb_id + '.' + result.headers['Content-Type'].split('/').pop()
>
>     # Insert the images in DB
>     dal_db.UserImageStore.insert(profile_image=profile_image_name,
>                                 profile_blob=profile_image,
>                                 upload_ts = datetime.now(),
>                                 change_ts = datetime.now()
>                             )
>     
>
>
> The same result is received from using urllib2 instead of urlfetch.
>

Reply via email to