Exemplo n.º 1
0
def upload_to_sfdc(request):
    gmail_service = Google.get_gmail_service(request.session['user_id'])
    attachment_id = request.GET['att_id']
    message_id = request.GET['msg_id']
    file_name = request.GET['file_name']
    attachment = gmail_service.users().messages().attachments().get(userId='me',
                                                                    messageId=message_id, id=attachment_id).execute()
    file_data = attachment['data']
    if file_data:
        sf_auth = Salesforce.objects.get(user__id=request.session['user_id'])
        Sfdc.insert_document(sf_auth, file_name, file_data)
    return HttpResponse('success')