Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if email_message.is_multipart():
- message = ''
- if "apply" in receiver_email.split('@')[0].split('_')[0] and isinstance(int(receiver_email.split('@')[0].split('_')[1]), int):
- for part in email_message.walk():
- content_type = str(part.get_content_type()).lower()
- content_dispo = str(part.get('Content-Disposition')).lower()
- print(content_type, content_dispo)
- if 'text/plain' in content_type and "attachment" not in content_dispo:
- message = part.get_payload()
- if content_type in ['application/pdf', 'text/plain', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'image/jpeg', 'image/jpg', 'image/png', 'image/gif'] and "attachment" in content_dispo:
- filename = part.get_filename()
- # open('/tmp/local' + filename, 'wb').write(part.get_payload(decode=True))
- # s3r.meta.client.upload_file('/tmp/local' + filename, bucket_to_upload, filename)
- data = {
- 'base64_resume': part.get_payload(),
- 'filename': filename,
- }
- data_list.append(data)
- try:
- api_data = {
- 'email_data': email_data,
- 'resumes_data': data_list
- }
- print(len(data_list))
- response = requests.post(url, data=json.dumps(api_data),
- headers={'content-type': 'application/json'})
- print(response.status_code, response.content)
- except Exception as e:
- print("error %s" % e)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement