Exemple #1
0
def upload_document():
    """
    Upload a document to the Box View service

    Expects a json with the following fields
        box_view_token: a valid box view token
        url: a valid url to pdf or office document
    """

    request_json = request.get_json()

    box_view_token = request_json['box_view_token']
    box_view_client = BoxViewClient(box_view_token)

    url = request_json['url']

    try:
        document = box_view_client.upload_document(url).json()
    except(BoxViewError):
        return jsonify({'error': 'an error occurred'}), 400

    print document
    document_id = document['id']

    print 'Document ID is {}'.format(document_id)

    return jsonify(document)
Exemple #2
0
def url_upload_document():
    """
    """
    box_view_client = BoxViewClient()
    document_url = request.form['document-url']

    try:
        document = box_view_client.upload_document(document_url)
    except(BoxViewError):
        return jsonify({'error': 'an error occurred'}), 400

    document_id = document.json()['id']
    print 'Document ID is {}'.format(document_id)

    return jsonify(document.json())
Exemple #3
0
def url_upload_document():
    """
    """
    box_view_client = BoxViewClient()
    document_url = request.form['document-url']

    try:
        document = box_view_client.upload_document(document_url)
    except (BoxViewError):
        return jsonify({'error': 'an error occurred'}), 400

    document_id = document.json()['id']
    print 'Document ID is {}'.format(document_id)

    return jsonify(document.json())