def ImageUrlToFile(image_url):
"""images are stored as ad-213213.png in the db. We get them from the website as
/static/upload-debug/ad-213213.png so we trim them.
Returns True, filepath"""
BAD_RETURN = False, ''
prefix = request.url_root + "static/%s/" % app.config[Constants.KEY_UPLOAD_DIR]
if not image_url.startswith(prefix):
return BAD_RETURN
a = image_url.split('/')
if not a or (image_url != prefix + a[-1]):
return BAD_RETURN
return True, a[-1]
评论列表
文章目录