def image_path(raw_image, prefix=''): path = datetime.now().strftime("%y/%m/%d") parts = path.split("/") parts = map(lambda x: short(int(x)), parts) image_name = md5(raw_image).hexdigest()[:8] return "%s/%s/%s.png" % ( prefix, "/".join(parts), image_name, )
def image_path(raw_image, prefix=''): path = datetime.now().strftime("%y/%m/%d") parts = path.split("/") parts = map(lambda x: short(int(x)), parts) image_name = md5(raw_image).hexdigest()[:8] return "%s/%s/%s.png" % (prefix, "/".join(parts), image_name, )
def path_to_short(path): id = redis.incr(_key("ID")) short_id = short(id) redis.set(_key(short_id), path) return short_id