Advertisement
Guest User

Untitled

a guest
Jan 17th, 2017
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. from google.appengine.api import images
  2. from google.appengine.ext import blobstore
  3.  
  4. def _get_urls_for(self, file_name):
  5. user = users.get_current_user()
  6. if user is None:
  7. return
  8.  
  9. bucket_name = app_identity.get_default_gcs_bucket_name()
  10. path = os.path.join('/', bucket_name, user.user_id(), file_name)
  11. real_path = '/gs' + path
  12. key = blobstore.create_gs_key(real_path)
  13. url = images.get_serving_url(key, size=0)
  14. thumbnail_url = images.get_serving_url(key, size=150, crop=True)
  15. return url, thumbnail_url
  16.  
  17. http://localhost:8080/_ah/img/encoded_gs_file:YXBwX2RlZmF1bHRfYnVja2V0LzE4NTgwNDc2NDIyMDEzOTEyNDExOC9pbWc4NzYuanBn=s32
  18.  
  19. http://localhost:8080/_ah/img/encoded_gs_file:YXBwX2RlZmF1bHRfYnVja2V0LzE4NTgwNDc2NDIyMDEzOTEyNDExOC9pbWc4NzYuanBn=s150-c
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement