Downloading files from dropbox or google drive

Hello everyone,
I’m Joan and I’m fifteen. Right now I’m developing an app which is supposed to be a tourist audioguide for my village church.

When I realised that I couldn’t exceed 10MB of storage, I’ve tried different ways to upload my audio files on the cloud, but with no luck. After many tries, google drive worked fine with the emulator, but when I built the apk and uploaded to google play, the app did not work. Later, I’ve changed the path from /mnt/scard/appinventor/assets (or something like that) to file:///storage/emulated/0/AppInventor/assets/, but didn’t work, either. When looking into the files of the phone, it seems as if audios were downloaded, but they are not their right size (they are lighter) and they can not be played.
Then, I’ve tried to use the dropbox method, but the result was the same, but in the emulator itself: the files seemed to be downloaded (but lighter and cannot be reproduced) and I get error 702 (unable to prepare files).
I’ve checked all your tutorials and I’m a bit lost, so any help will be appreciated.
Enclosed you’ll find the dropbox cose, as I’m not allowed to upload more images.
Thanks,
Joan.

@Taifun has put together some procedures here
https://puravidaapps.com/filebyfile.php
Have you tried them?

1 Like

The two file paths you refer to are for assets uploaded in the Media area, and are only available/visible on the device during development. Once compiled, the assets folder is only available to the app. You cannot use these folders to download files to.

You should look to create a folder on the sdcard (the internal storage of the device) which is read/writeable - you may need to get a permission (WRITE_EXTERNAL_STORAGE) for this. That path would then be /mnt/sdcard/YourFolder, file:///mnt/sdcard/YourFolder or file:///storage/emulated/0/YourFolder.

Whether you use google drive or dropbox is up to you, if you follow the link above provided by @Red_Panda you should see a link to a google drive example

Hi and thank you for your replies.

@Red_Panda, I had already checked all procedures from Taifun, but I couldn’t find the way out.

@TIMAI2 , I’ve changed the path as you told me in my google drive attempt, but the problem remains the same: sometimes I get the error “unable to prepare the file”; sometimes I don’t get any errors, but the audios cannot be heard. I think they are not properly downloaded, because I look into my phone through a file manager app and I find the files in the right path, but they are not “playable”. That is, the files are 224B, when they should be 300MB aprox. I enclose a screenshot of this, too.

I’m afraid there is an error in the dowloading process and I was wondering if it might have something to do with the WRITE_EXTERNAL_STORAGE permission. Once I run the app for the first time, I get this error, but when I modify the permissions in the app settings, it disappears. I read somewhere I could modify this by decompiling the .apk file with apptomarket and changing the android manifest, but I’m not sure if that is necessary, nor how to do it.

I enclose a screenshot of the google drive attempt, which I copied from a mixture of the turorials mentioned. If you find any code errors on both screenshots, please let me know, so I can fix it.!


Screenshot_2020-01-01-23-46-21|281x500

Thanks again for your help.

You can set/ask for permission WRITE_EXTERNAL_STORAGE in Screen1.Initialise. If using the companion the permission should already be in place.

300mb for each file ??? Will your users really want to download +2GB of files before they can use the app (maybe on their data connection ?)

In your screenshot your file path doesn’t appear to match the download to path in the blocks ?

Hi,
Thanks for your reply, @TIMAI2. I’ve solved the permission problem following your instructions.
I’ve also checked the audios and I was mistaken, as the heaviest are 3MB, so that should not be a problem. Besides, the church has wi-fi, so visitors will download the app from there.
I don’t understand what you mean at the last sentence with the two paths not macthing. Could you please be more specific. I don’t know what you mean.

Thanks again for your quick reply!

image

image

Hi,
The problem with the path mismatch was because I tried so many paths that the screenshot was not correct, thanks for letting me know.

As I could not find the reason why the audios were not properly downloaded, I’ve finally decided to split the app into three: one for Catalan, one for Spanish and one for French. That way, I can include the audios in the apk file and everything works fine. Having three apps is not the best solution, but it is the only one I can figure out (and works).

Thanks for all your help!

If I had to make a multilanguage app, here’s how I would do it

  1. Retrieve the locale of the user and set all texts accordingly (this can either be done with the built-in blocks or using my I18n extension
  2. Either upload all files to the assets or download the correct files on the first start of the app

Tim,

Can you offer any input regarding downloading images from Dropbox. I'm done with google drive for now. I need another location to store images. Totally unfamiliar with Dropbox, but I'm willing to learn.

Thanks!

Sorry, no experience of Dropbox.

I suggest you set up your own VPS server to run php or perhaps to use ftp....

Here is Taifun's App Inventor DropBox example https://puravidaapps.com/dropbox.php

Tim here is what i found out regarding image hosting.. Dropbox was not intended to be used as a web host. They even disabled the ability to render HTML files to prevent hostsing entire pages on Dropbox. If image web hosting is what you need, then you should really be using a proper web host that will serve up the raw images without any parameters in the URL.

who do you use for your web hosting?

Have you tried imgBB ?