Backup in users google drive

I have written an app and it works. The app store all results at this time in the ASD of the app (Android 11).

Now i want give all the users of the app a chance to backup the results in their own google drive and a chance to restore the data back to the app.

The app should create a directory with the name of the app and inside 2 files (a database file and a zip-file) copied from the ASD in the users google drive.

Is there a extension, that will work for me? Can anyone help me to do this?

Sorry for my bad english.

Frank

1 Like

https://community.appinventor.mit.edu/t/gd-connector-connect-users-to-their-own-google-drive-and-google-sheets/52783/9

@TIMAI2

Thank you for your fast help.

I am a noob store files to google drive using an app or script.

I have load the demo aia (GDConnectorDemoV2.aia) and will give it a try.

The app needs some global variables (script url, folderID, sheetID ...).

The app won't work without this information, correct?

As a developer, and above all as a user, where do I get this information from inside the app?

Frank

1 Like

I made this clear in the instructions....

Make sure you create the google apps script web app, otherwise the aia will not work.

@TIMAI2
Thank you.

I have create the google apps script web app and and now I'm testing your demo.

I'll see if I understand your demo app.

If I have any questions, I'll get back to you.

Frank

Also, if you need to be able to create a zip file:

Alternatively, you can have this for a small amount.

@vknow360
Thanks for the tip, but I'll stick with TimAI2's extension.

@TimAI2
I use the ZIP extension and have a problem there with Android 11. I will open a new topic for this.

Frank

@TIMAI2

In Companion Auth works properly. I will test it in my app later.

Here my first question:

I use the call "GetRootFolders" and can see a result in the WebViewer.
How can I use "GotRootFolders" to query whether a folder already exists in the root?

Example: I want to know if the "Testapp" folder exists in the root?

Can you please help me?

Frank

Apart from authentication, you should not need to view the webviewer.

The output of getRootFolders is returned to the webviewstring, you can then use the JSON.parse block in the extension to convert the output to a list. You can then check if "Testapp" exists in the list.

Thanks TIMAI2,

can you please show me a block.

Frank

This set of blocks is important, you should at least have this:

image

Then you can make a call for getRootFolders
image

When the data is returned ( a stringified JSON array with each foldername and folderID):

@TIMAI2

Thank you very much, it works.

Frank

Hello TIMAI2,

you wrote that the folderID is also given in the stringified JSON array. How can I read out the folderID for my folder name "Testapp"?
Can you please show me a block for that too?

I definitely need this folderID for the TargetID in "UploadFileToFolder", correct?

Thanks Frank

You need index 2 from the item in global RootFolders (when you do a for each item)

Thank you TIMAI2

One more question, sorry.

What is the targetID in "UploadFileTo Folder"? Is this the folderID of the "Testapp" folder?
Or how does the tagetID have to be assigned?

Frank

The targetID is the Id of the folder you wish to upload the file to. You use the folderID for this. Therefore if you want to upload a file to the folder "Testapp", you must get this folders ID and set it as the targetID. :slight_smile:

Hello TIMAI2,

it still doesn't work.
Here the block:

There is no error message, the file is not written to the folder in Google Drive.
I checked the folderID, it gives the correct name for the folder.

What have I done wrong?

Frank

Possible omission by me, there is no db file type in the MimetypesList and I should have put application/octet-stream in the notFound socket like so:

Also edit global filename to just filename

Also, you can debug all of your variables to ensure that they are correct - e.g. do you actually have a base64string, is the filename returning true, is the target folderID in place

Hello TIMAI2,

with a small file (*.db) it works now. The file ends up in the right folder on GD.

Then I tried a zip file with a size of about 10MB. This file is not written to GD.

My block for this is:

Frank