Как загрузить данные, такие как изображения, PDF и excel файлы в DevExtreme File Manager?

У меня есть приложение, в котором я хочу показать копию структуры папок google drive в моем приложении. Я могу получить данные с google drive через его API. Но у меня возникают трудности с загрузкой этих данных в библиотеку FileManager в DevExtreme. Также как отправить данные, полученные с бэкенда, через AJAX-запрос (POST|GET).

Файл, полученный от API:

    from pydrive2.auth import GoogleAuth
    from pydrive2.drive import GoogleDrive
    gauth = GoogleAuth()
    gauth.LoadCredentialsFile("mycreds.txt")
    if gauth.credentials is None:
        # Authenticate if they're not there
        gauth.LocalWebserverAuth()
    elif gauth.access_token_expired:
        # Refresh them if expired
        gauth.Refresh()
    else:
        # Initialize the saved creds
        gauth.Authorize()
    # Save the current credentials to a file
    gauth.SaveCredentialsFile("mycreds.txt")

    img = drive.CreateFile({'id': file_id})
    img.GetContentFile('sample.jpg')

Код для создания файлового менеджера из Javascript:

data = [
    {
        name: "MyFile.jpg",
        size: 1024,
        dateModified: "2019/05/08",
        thumbnail: "/thumbnails/images/jpeg.ico",
        isDirectory: true,
        items: [
            // ...
            // Nested data objects with the same structure
            // ...
        ]
    }
]

new DevExpress.ui.dxFileManager(document.getElementById("file-manager"), {
    "fileSystemProvider": data,
    "itemView": {
        "mode": "thumbnails"
    },
    "permissions": {
        "copy": true,
        "create": true,
        "delete": true,
        "download": true,
        "move": true,
        "rename": true,
        "upload": true
    },
    "rootFolderName": "PayUP",
    "rtlEnabled": false,
    "currentPath": path,
    onSelectionChanged: function (e) {
        console.log(e)
    }
});

Мне нужно, как добавить загруженное изображение в data выше из Django backend через ajax на сторону клиента. Это DevExtreme File Manager

Вернуться на верх