Django загружает файл в Dropbox
Есть ли способ загрузить файл из Django в Dropbox, как показано ниже для справки: Создаем одну папку в корневом каталоге, затем копируем все файлы из корневого каталога в dropbox.
TOKEN = "xxxxxxx"
LOCALFILE = os.path.join(settings.BASE_DIR, 'dcfiles')
BACKUPPATH = "/Apps/backup/"# Keep the forward slash before destination filename
dbx = dropbox.Dropbox(TOKEN)
dbx.files_upload(LOCALFILE, BACKUPPATH)
Ошибка:
Internal Server Error: /app01/strequest/
Traceback (most recent call last):
File "/Users/imac/Desktop/Project/Test2/myenv/lib/python3.12/site-packages/django/core/handlers/exception.py", line 55, in inner
response = get_response(request)
^^^^^^^^^^^^^^^^^^^^^
File "/Users/imac/Desktop/Project/Test2/myenv/lib/python3.12/site-packages/django/core/handlers/base.py", line 197, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/imac/Desktop/Project/Test2/myenv/lib/python3.12/site-packages/django/views/decorators/csrf.py", line 65, in _view_wrapper
return view_func(request, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/imac/Desktop/Project/Test2/test2/app01/views.py", line 35, in strequest
dbx.files_upload(LOCALFILE, BACKUPPATH)
File "/Users/imac/Desktop/Project/Test2/myenv/lib/python3.12/site-packages/dropbox/base.py", line 3214, in files_upload
r = self.request(
^^^^^^^^^^^^^
File "/Users/imac/Desktop/Project/Test2/myenv/lib/python3.12/site-packages/dropbox/dropbox_client.py", line 326, in request
res = self.request_json_string_with_retry(host,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/imac/Desktop/Project/Test2/myenv/lib/python3.12/site-packages/dropbox/dropbox_client.py", line 476, in request_json_string_with_retry
return self.request_json_string(host,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/imac/Desktop/Project/Test2/myenv/lib/python3.12/site-packages/dropbox/dropbox_client.py", line 538, in request_json_string
raise TypeError('expected request_binary as binary type, got %s' %
TypeError: expected request_binary as binary type, got <class 'str'>