Hello.
I'm part of a project and i need to export all the Dropbox's files to Nakala which is a data warehouse.
I'm having difficulties listing the Dropbox folders, i think the script doesnt recognize them even when i have the right path to them

Here is the code :
Spoiler
import dropbox
import requests
# Dropbox and Nakala authentication
DROPBOX_ACCESS_TOKEN = ''
NAKALA_API_URL = "https://apitest.nakala.fr/data/"
NAKALA_API_KEY = "01234567-89ab-cdef-0123-456789abcdef"
dbx = dropbox.Dropbox(DROPBOX_ACCESS_TOKEN)
# Step 1: Recursively list folders and files in Dropbox
def list_all_folders_and_upload_to_nakala(folder_path=""):
try:
result = dbx.files_list_folder(folder_path, recursive=True)
print("Folders and files in Dropbox:")
for entry in result.entries:
if isinstance(entry, dropbox.files.FileMetadata):
file_path_in_dropbox = entry.path_lower
print(f"Processing file: {file_path_in_dropbox}")
# Download the file from Dropbox
file_content = download_from_dropbox(file_path_in_dropbox)
# Upload to Nakala
if file_content:
print(f"Uploading {entry.name} to Nakala...")
upload_to_nakala(entry.name, file_content)
elif isinstance(entry, dropbox.files.FolderMetadata):
print(f"Folder: {entry.path_display}")
except Exception as e:
print(f"Error listing Dropbox folders: {e}")
# Step 2: Download file from Dropbox
def download_from_dropbox(file_path):
try:
metadata, res = dbx.files_download(path=file_path)
print(f"Downloaded: {file_path}")
return res.content
except Exception as e:
print(f"Error downloading from Dropbox: {e}")
return None
# Step 3: Upload file to Nakala
def upload_to_nakala(file_name, file_content):
files = {
'file': (file_name, file_content),
}
headers = {
'Authorization': f'Bearer {NAKALA_API_KEY}',
}
try:
response = requests.post(NAKALA_API_URL, headers=headers, files=files)
if response.status_code == 200:
print(f"File {file_name} uploaded successfully to Nakala!")
else:
print(f"Error uploading {file_name} to Nakala: {response.status_code}, {response.text}")
except Exception as e:
print(f"Error during Nakala upload: {e}")
# Main workflow
folder_path_in_dropbox = "/Sète"
list_all_folders_and_upload_to_nakala(folder_path_in_dropbox)
I would like to know why this doesnt work, when i have the folder created

Thanks you.