Forum Discussion

eaev's avatar
eaev
New member | Level 1
12 days ago

Can't access shared folder metadata

Hello,

I have a folder that has been shared with me (I am a co-owner), from which I need to download several files. I am trying to do this with the dropbox Python API so that I don't have to manually generate a shared link for each file. I am able to generate and use an API token, however it seems like the dropbox object can only see what has been downloaded to my personal laptop. I don't have enough storage space to download the full shared folder, and it is not showing up at all in the dropbox folder on my computer, so I can't set it to be online-only as many forums suggest.

How can I download and upload files to this shared folder without needing to first put the whole thing on my laptop?

  • paulraun's avatar
    paulraun
    New member | Level 1

    You can use the Dropbox API to list and download files from a shared folder without syncing it to your local storage. Try the following:

    Use the correct API endpoint – Ensure you're using files_list_folder with the shared_link parameter to access the shared folder directly.
    Check folder access – Confirm you have the correct permissions (shared_folder_member_list may help verify this).
    Download files individually – Use files_download to fetch specific files without syncing the entire folder.

    Here's a Python script using the Dropbox API to list and download files from a shared folder without syncing the entire folder to your local storage.

    Prerequisites:
    Install the Dropbox SDK:
    pip install dropbox

         2. Get your Dropbox API token from the Dropbox App Console.

         3. Use the shared link of the folder you need access to.

    Python Script to List & Download Files from a Shared Folder


    import dropbox # Replace with your Dropbox API token ACCESS_TOKEN = "your_access_token" # Replace with the shared folder link SHARED_LINK = "https://www.dropbox.com/scl/fo/somefolderid" # Initialize Dropbox client dbx = dropbox.Dropbox(ACCESS_TOKEN) def get_shared_folder_metadata(): """Get metadata of the shared folder.""" shared_link = dropbox.files.SharedLink(url=SHARED_LINK) try: folder_metadata = dbx.files_list_folder(path="", shared_link=shared_link) return folder_metadata.entries except dropbox.exceptions.ApiError as e: print(f"Error accessing shared folder: {e}") return [] def download_file(file_path, local_path): """Download a file from Dropbox to local storage.""" try: metadata, res = dbx.files_download(path=file_path) with open(local_path, "wb") as f: f.write(res.content) print(f"Downloaded: {file_path} -> {local_path}") except dropbox.exceptions.ApiError as e: print(f"Error downloading {file_path}: {e}") # List and download files files = get_shared_folder_metadata() for file in files: if isinstance(file, dropbox.files.FileMetadata): # Ensure it's a file, not a folder download_file(file.path_lower, file.name)

    How It Works:
    Lists all files in the shared folder using the shared link.
    Downloads each file without needing to sync the full folder.
    Saves files locally with the same name. 

  • DB-Des's avatar
    DB-Des
    Icon for Dropbox Engineer rankDropbox Engineer

    Hi eaev,

    In order for a shared folder to show in your Dropbox account, or the Dropbox folder on your computer, you need to ensure you have joined the folder after you were added to it as a member. You can do so by:

    1. Log in to dropbox.com.
    2. Click Home in the left navigation bar.
    3. Click Shared in the left sidebar.
    4. Find the shared folder you want to access. 
    5. Hover over the folder you’d like to join and select Join folder.

     

    Once you have joined this shared folder, it should be available for you to interact with (uploading and downloading files, in your case) using the API, without needing to download the folder and all of its contents locally.

    You can reference this example for an idea on how to upload and download documents using the Python SDK.

    You also mentioned:

    I am able to generate and use an API token, however it seems like the dropbox object can only see what has been downloaded to my personal laptop

    To clarify, when sending requests to the Dropbox API, the information returned is information stored on our servers, not information stored locally on your computer.

    I hope you find this information helpful!

  • eaev's avatar
    eaev
    New member | Level 1

    Hello,

    This worked! Thanks for your response. I figured out that this was failing because I had not used DropBox before and I was using the wrong links (ones from the Box version of this folder instead of the correct DropBox links).

    For the other problem, I am unable to join the shared folder as I don't have enough storage space in my account (even though only the uploader should technically need that much space - viewing files doesn't take up space in the viewer's account), but as long as I can download and upload files to the shared folder then I should be fine without that.

  • eaev's avatar
    eaev
    New member | Level 1

    Thank you! Yes, I am more saying that the development team should consider removing that stipulation - shared folders should count towards the uploader's storage space instead of the person it is shared with, unless that person wants to download it. There is a lot about Dropbox I don't understand, but from a new user's perspective it seems like having to keep the original shared link around anytime I want to access the folder (instead of just being able to view it from my account) is a pain.

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.5,951 PostsLatest Activity: 3 hours ago
352 Following

If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X or Facebook.

For more info on available support options for your Dropbox plan, see this article.

If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!