Want to know more about Dash? Check out how Amy uses Dropbox and Dash to make her day easier here! 

Forum Discussion

Jon B.1's avatar
Jon B.1
Collaborator | Level 9
10 months ago

Offline files not downloaded when accessed programmatically (macOS)

Not sure where best to address this question, but it would appear to be API-related...

 

We've got an existing app which has been working OK until recently on both Windows and Mac platforms, which accesses XML files stored in the user's local Dropbox folder.  (The app is mainly cross-platform C++ with a thin layer of platform-specific code, which on the Mac side is Swift-based.)  Until now, this has worked fine; while we use SwiftyDropbox on the Mac side for other communication with Dropbox, we haven't had to download the files through the API, we've relied on the Dropbox client app for that.

 

But now a user, having done a clean install on a Mac, is reporting that the files are showing up as zero bytes; this would appear to be because they're arriving from the shared Dropbox folder and have not been synced locally for offline access, which I understand is the new default behaviour (though I note that the user is not yet running the FileProvider version of Mac Dropbox).

 

The concern is that, while clicking on the file in Finder in the local Dropbox folder to open it triggers a sync and successfully opens the file...  opening the file from within our C++ code doesn't.  When we try to read it using standard ifstream and ostringstream calls, we get an empty buffer.

 

Once we double-click the file in Finder, it reads it correctly (without even restarting our app).  And the open calls still work fine with the same version of the Dropbox client on other machines, with files which are synced locally.

 

So question #1 is, what do we need to do to open the file inside our program the same way as double-clicking in Finder?  That would seem to be the simplest way to make the problem go away.  (We could do this in either the C++ or Swift code as needed.)

 

Question #2 is, is there any way to force these XML files *programmatically* to be available offline?  Again, that would pre-empt the whole problem.  Is there anything in the SwiftyDropboxAPI which can set a file to be synced locally?

 

Failing that, our least-preferred solution is to download the XML file as a file through SwiftyDropbox, bypassing the local sync directory, and reading it like that.  This would require a wider-scale re-engineering of our app, so we'd rather not do that at this point if we can help us.

 

Which raises question #3 -- is this an issue which can be fixed by having the user upgrade to the FileProvider version?  Will that resolve those kinds of sync issues?  They're currently using client version 206.4.6506 on Sonoma 14.6.1; are there known issues there?

 

(For the record, there seems to be something flaky about their Dropbox installation to begin with; the Dropbox shortcut link in the left-hand pane of the Finder window isn't showing the Dropbox icon, and there are no sync icons.  I've suggested a reinstall, and will update as we get more information.

 

9 Replies

  • Jon B.1's avatar
    Jon B.1
    Collaborator | Level 9
    10 months ago

    Yes, 14.6.1, and the Dropbox client was tried with a couple of different versions (including upgrading to FileProvider).

  • DBoxTips's avatar
    DBoxTips
    Experienced | Level 13
    10 months ago
    Thank you for reporting back your results.

    To confirm (and to try reproducing this on my end): is this on Sonoma 14.6.1?

    Thanks,
    Andrew (DBoxTips)
  • Jon B.1's avatar
    Jon B.1
    Collaborator | Level 9
    10 months ago

    Hello Andrew!

     

    Ran the test program on a 4K XML file, which exists and is readable on the website, but shows up as 0 bytes in Finder.  It reported the error "File size is zero bytes. Nothing to be downloaded" -- so it doesn't get as far as attempting to read the file.  When I comment out the return in that clause of the test program, it continues on and reports "Failure. File is still online-only".  The file remains un-synced.  In the other cases where we've tried it, double-clicking in Finder will sync it, but I haven't done that yet.

     

    In other news, the user has upgraded to the FileProvider version of Dropbox client, and it hasn't fixed the problem.

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    10 months ago

    Jon B.1 

     

    1. This is more of a local filesystem interaction, so I can't offer much guidance here unfortunately, as I can only offer help with the Dropbox API itself. If you want to open a ticket though and reference this thread, we can direct your ticket to the relevant department to see if they can offer some guidance on that, though I can't make any guarantees.

     

    2. The official Dropbox API/SDK does not offer an interface for managing the online/offline setting for files on the desktop, but I'll pass this along as a feature request. I can't promise if or when that might be implemented though.

     

    3. This may be something for the user to directly contact support about.

  • DBoxTips's avatar
    DBoxTips
    Experienced | Level 13
    10 months ago
    We can do that in this case, but if possible we'd rather not force all Mac users to sync everything locally, so it would be better to automate it! Thanks, though.

    Apologies, from your initial post I wrongly assumed this a dedicated setup for one machine, not a software shipped to multiple users. Normally, opening a handle to an online-only file in order to read from it should be enough to trigger the download by the Dropbox desktop client.

     

    I would try to reproduce the issue using a simpler test program and then contact Dropbox support and ask about it. 

     

    Here is simple test C program that you can use to reproduce and isolate the issue on a smaller scale. You could try compiling and running it and then report the results here.

     

    Hope this helps,

    Andrew (DBoxTips)

     

    I am an individual contributor to the Dropbox Community forums, not affiliated with Dropbox. All opinions expressed here are my own.

  • Здравко's avatar
    Здравко
    Legendary | Level 20
    10 months ago

    Hi Jon B.1,

    Your issue is just one symptom of a bigger problem related to Dropbox application. It's not something related to Dropbox API. Unfortunately, the application' developers are too lazy, as it seems, to prepare and publish documentation for the application exported features. 🤷 That's it.

    One way you may try to workaround the issue is open desired files with a pre-built system dialog. They are usually components of corresponding system file manager (Finder, Windows File explorer, etc) and behave in the same way. So likely they will trigger sync of the corresponding file in Dropbox folder. Try at least.

    Good luck.

  • Jon B.1's avatar
    Jon B.1
    Collaborator | Level 9
    10 months ago

    We can do that in this case, but if possible we'd rather not force all Mac users to sync everything locally, so it would be better to automate it!  Thanks, though.

  • DBoxTips's avatar
    DBoxTips
    Experienced | Level 13
    10 months ago
    Hello,

    Would it work for you to right-click the Dropbox folder and pick the “Make available offline” option from the Dropbox context menu and from the Dropbox preferences to set new files to sync as offline?

    That would allow you to keep the existing app architecture.

    Hope this helps,
    Andrew (DBoxTips)

About Dropbox API Support & Feedback

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

The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.

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!