Advertisement
Guest User

Untitled

a guest
May 22nd, 2018
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.67 KB | None | 0 0
  1. def callback_converter(ch, method, properties, body):
  2.     json_get = json.loads(body)
  3.     file_path = json_get['file_path']
  4.     print file_path
  5.     response = requests.get(file_path)
  6.     content_type = response.headers['content-type']
  7.     extension = mimetypes.guess_extension(content_type)
  8.     hash = uuid.uuid4().hex
  9.     fullPath = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) + '/converter-node/files/' + hash + extension
  10.     with open(fullPath, 'wb') as f:
  11.         f.write(response.content)
  12.  
  13. connector = Connection(host='35.198.191.27', login='prosperodesu', password='s45fdfx65')
  14. connector.addCallback('convert', callback_converter)
  15. connector.start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement