Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def write_file(data, filename):
- with open(filename, 'wb') as f:
- f.write(data)
- class DownloadPhoto(Resource):
- def get(self,PhotoDefaultID):
- connection_DownloadPhoto = pymysql.connect(host='*******',
- user='root',
- password='*****',
- db='*******',
- charset='******',
- cursorclass=pymysql.cursors.DictCursor)
- try:
- with connection_DownloadPhoto.cursor() as cursor_DownloadPhoto:
- DownloadPhoto = "SELECT `PhotoData` FROM `app_phototable` WHERE `PhotoDefaultID` IN (%s)"
- cursor_DownloadPhoto.execute(DownloadPhoto, PhotoDefaultID)
- PhotoData = cursor_DownloadPhoto.fetchone()
- connection_DownloadPhoto.commit()
- finally:
- connection_DownloadPhoto.close()
- #write_file(data=PhotoData, filename="PhotoFile")
- write_file(PhotoData, "PhotoFile")
- return send_file(filename_or_fp= "PhotoFile", mimetype="image/jpeg"), 200
Add Comment
Please, Sign In to add comment