예제 #1
0
def upload_file(parent_id, file_path, title, description, mimetype):
    """Upload a file to a google drive folder.

    Args:
        parent_id (str):
            Identifier for the drive folder to upload to.
        file_path (str):
            Local file path to the file to upload.
        title (str):
            Title for the uploaded document.
        description (str):
            A description of the file to upload.
        mimetype (str):
            Mimetype of the uploaded content.

    Returns:
        file_metadata (dict):
            A Google Apps File resource with metadata about the uploaded file.
    """

    service = Service(settings.GOOGLE_P12_PATH,
                      settings.GOOGLE_SERVICE_EMAIL)
    file_metadata = service.insert_file(
        title,
        description,
        parent_id,
        mimetype,
        file_path
    )
    return file_metadata
예제 #2
0
def upload_file(parent_id, file_path, title, description, mimetype):
    """Upload a file to a google drive folder.

    Args:
        parent_id (str):
            Identifier for the drive folder to upload to.
        file_path (str):
            Local file path to the file to upload.
        title (str):
            Title for the uploaded document.
        description (str):
            A description of the file to upload.
        mimetype (str):
            Mimetype of the uploaded content.

    Returns:
        file_metadata (dict):
            A Google Apps File resource with metadata about the uploaded file.
    """

    service = Service(settings.GOOGLE_P12_PATH,
                      settings.GOOGLE_SERVICE_EMAIL)
    file_metadata = service.insert_file(
        title,
        description,
        parent_id,
        mimetype,
        mimetype,
        file_path
    )
    return file_metadata
예제 #3
0
def _upload_csv_to_google(spreadsheet_name, file):
    service = Service(settings.GOOGLE_P12_PATH, settings.GOOGLE_SERVICE_EMAIL)
    sheet = service.insert_file(
        spreadsheet_name, '',
        settings.ORCHESTRA_TODO_LIST_TEMPLATE_EXPORT_GDRIVE_FOLDER, 'text/csv',
        'application/vnd.google-apps.spreadsheet', file.name)
    service.add_permission(sheet['id'], write_with_link_permission)
    return sheet['alternateLink']