Как указать корневой путь к папке Dropbox с помощью вызова API PythonPython

Программы на Python
Anonymous
Как указать корневой путь к папке Dropbox с помощью вызова API Python

Сообщение Anonymous »

Я пытаюсь написать базовый API для чтения файлов в моей корневой папке Dropbox, передавая пустую строку, представляющую корень. Однако он возвращает ошибку проверки:
ValidationError("'%s' did not match pattern '%s'"
stone.backends.python_rsrc.stone_validators.ValidationError: 'test.txt' did not match pattern '(/(.|[\r\n])*|id:.*)|(rev:[0-9a-f]{9,})|(ns:[0-9]+(/.*)?)'

Мой звонок:
# Path to the Dropbox folder you want to read files from
FOLDER_PATH = ""

def read_files_from_folder():
# Create a Dropbox client
dbx = dropbox.Dropbox(TOKEN)

try:
# Get the list of files in the specified folder
files = dbx.files_list_folder(FOLDER_PATH).entries

for file in files:
# Get the file metadata
metadata = dbx.files_get_metadata(file.path_display)

# Check if the file is a file (not a folder)
if isinstance(metadata, dropbox.files.FileMetadata):
# Get the file contents
file_path = os.path.join(FOLDER_PATH, metadata.name)
_, res = dbx.files_download(file_path)
file_contents = res.content

# Process the file contents as needed
print(f"File Name: {metadata.name}")
print(f"File Contents:\n{file_contents}\n{'=' * 50}")

except dropbox.exceptions.ApiError as e:
print(f"An error occurred: {e}")

# Call the function to read files from the Dropbox folder
read_files_from_folder()


Подробнее здесь: https://stackoverflow.com/questions/764 ... n-api-call

Вернуться в «Python»