示例#1
0
def download_image(token):
	if token != None and list_token_id.has_key(token):
		filename=database_helper.get_name_image(list_token_id.get(token))
		if filename!='' and filename!=None:
			if os.path.isfile(UPLOAD_FOLDER+'/'+filename): #check if file exist
				result=send_from_directory(UPLOAD_FOLDER,filename, as_attachment=True)
				return result
			else:
				return bytearray([])
		else:
			return bytearray([])
	else:
		return bytearray([])
示例#2
0
def download_image_by_email(token,email):
	if token != None and list_token_id.has_key(token) and email != None:
		id_user=database_helper.get_id_by_email(email)
		if id_user=='wrong email':
			return bytearray([])			
		filename=database_helper.get_name_image(id_user)
		if filename!='' and filename!=None:
			if os.path.isfile(UPLOAD_FOLDER+'/'+filename): #check if file exist
				result=send_from_directory(UPLOAD_FOLDER,filename, as_attachment=True)
				return result
			else:
				return bytearray([])
		else:
			return bytearray([])
	else:
		return bytearray([])