Guest User

Untitled

a guest
Jun 12th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. def write_file(data, filename):
  2. with open(filename, 'wb') as f:
  3. f.write(data)
  4.  
  5. class DownloadPhoto(Resource):
  6. def get(self,PhotoDefaultID):
  7. connection_DownloadPhoto = pymysql.connect(host='*******',
  8. user='root',
  9. password='*****',
  10. db='*******',
  11. charset='******',
  12. cursorclass=pymysql.cursors.DictCursor)
  13. try:
  14. with connection_DownloadPhoto.cursor() as cursor_DownloadPhoto:
  15. DownloadPhoto = "SELECT `PhotoData` FROM `app_phototable` WHERE `PhotoDefaultID` IN (%s)"
  16. cursor_DownloadPhoto.execute(DownloadPhoto, PhotoDefaultID)
  17. PhotoData = cursor_DownloadPhoto.fetchone()
  18. connection_DownloadPhoto.commit()
  19. finally:
  20. connection_DownloadPhoto.close()
  21. #write_file(data=PhotoData, filename="PhotoFile")
  22. write_file(PhotoData, "PhotoFile")
  23. return send_file(filename_or_fp= "PhotoFile", mimetype="image/jpeg"), 200
Add Comment
Please, Sign In to add comment