Page 1 of 1
Saving/loading files from the cloud?
Posted: Fri Aug 09, 2024 12:59 am
by BarryG
One of my users has asked if my app's data files can be saved to the cloud, so they can be accessed from any PC that my app is run from, without him having to copy the data files to each PC manually. How would I do this? Say for Google Drive or DropBox?
Re: Saving/loading files from the cloud?
Posted: Fri Aug 09, 2024 1:23 am
by normeus
BarryG,
For Dropbox, or google drive it is just a folder on your PC, PCloud is an actual drive p: onedrive/skydrive is also a folder in documents. When the user runs the program you have to make sure the datafile is not open by another user (or same user in a different pc) so you'll have to create some kind of file lock, I just use a text file with the computer name that has open the data files and once the data file closes you delete that text file. I use the computer name so that users know who to call and ask to get off the computer. If you dont manage file locking you'll endup with mutiple versions of your datafiles.
Norm.
Re: Saving/loading files from the cloud?
Posted: Fri Aug 09, 2024 2:00 am
by BarryG
Okay, I'll download Google Drive on my PC (the app) and give it a try. Thanks!
I just thought there was a non-app way, kind of like FTP or something.
Re: Saving/loading files from the cloud?
Posted: Fri Aug 09, 2024 2:03 am
by skywalk
I don't remember it being so simple.
Authentication and error checking is critical.
Search for libcurl or chilkat.
Re: Saving/loading files from the cloud?
Posted: Fri Aug 09, 2024 2:23 am
by BarryG
I installed the Google Drive app and now I have a G: drive for it in Explorer:
So I tried it, and it works!

Can't believe it was this simple:

Re: [Solved] Saving/loading files from the cloud?
Posted: Fri Aug 09, 2024 8:39 am
by HeX0R
I'm doing this since years, with pcloud to synchronize files accross different PCs (and even Smartphones)
Re: [Solved] Saving/loading files from the cloud?
Posted: Fri Aug 09, 2024 1:18 pm
by BarryG
One issue: how can my app tell if it's using Google Drive (or any other cloud provider)? FileSize() still correctly returns -2 for any online folder, and GetDriveType_() returns #DRIVE_FIXED instead of #DRIVE_REMOTE for it. I need my app to behave a bit differently if an online folder is being used, but from my testing it seems I can't differentiate between a real local folder and a remote one.
Re: [Solved] Saving/loading files from the cloud?
Posted: Fri Aug 09, 2024 3:38 pm
by skywalk
Ah, so you are relying on an existing network drive?
Authentication is handled by the user.
I thought your app was supposed to connect to the cloud drive.
Re: Saving/loading files from the cloud?
Posted: Sat Aug 10, 2024 3:19 am
by BarryG
skywalk wrote: Fri Aug 09, 2024 3:38 pmAh, so you are relying on an existing network drive?
Yes, as shown in the screenshots above. I haven't coded anything myself as I have zero network knowledge and skills.
Anyone know how to tell if my app is using a network drive as opposed to a local fixed one? See my post a bit further up.
Re: Saving/loading files from the cloud?
Posted: Sat Aug 10, 2024 6:39 am
by TI-994A
BarryG wrote: Fri Aug 09, 2024 12:59 am...app's data files can be saved to the cloud, so they can be accessed from any PC that my app is run from...
While conventional wisdom would recommend some form of cloud app hosting, you could also simply set up a local NAS. This would be the easiest solution if all the PCs are on the same LAN. However, even if the NAS requires online access, it wouldn't be too difficult to set up a local server on the premises with some port forwarding. The NAS would then be accessed through the server through some script. Granted, connectivity wouldn't be lightning fast, but for such requirements, it shouldn't pose much of an issue.
Another option would be to go old-school and utilise Windows network sharing. With some port forwarding, it too could be accessed online.
App hosting starts cheap, but could scale very fast depending on usage.

Re: Saving/loading files from the cloud?
Posted: Sat Aug 10, 2024 6:51 am
by normeus
I just assume it is a cloud drive and handle the data accordingly ( locking files while the program is running, etc..)
maybe this could help for google drive:
https://www.purebasic.fr/english/viewto ... 42#p487042
pcloud is p: drive with a "pCloud Drive" label
dropbox is a folder , same with OneDrive. (c:\user\Normeus\Dropbox and c:\user\Normeus\OneDrive)
I do not have google drive but it might be as simple as the others.
Norm.