Mysterious file management

Yes, when you get the url, also get the filename, and add this to a separate list that corresponds to the url list, e.g.

image

Then set the responsefilename to the actual filename in the filenames list using the url index:

I looked to see if there was a default limit on the number of downloads over a given time set up on Google Drive, but I couldn't find anything convincing...
And if I find a way to download an entire file at once, won't Google count the 14 downloads anyway?

Users discovered, at the beginning of 2023, that Google had introduced a limit of 5,000,000 files created per user without warning anyone, which was a scandal. But that doesn't concern me in my situation, it just shows that Google is capable of introducing hidden limitations without warning anyone...

I will write to them. But without much hope...

Yes, but you only do it once, after you have the 14 files, everything will happen on your phone/device, no more downloading....

Yes, you're right. However, when you manually download a folder from a computer, Google Drive offers a .Zip file. If it were possible to reproduce this from App Inventor: this one, by downloading a folder which is automatically unzipped on the phone, it would already be not bad and transparent for teachers. It would be enough to tell them that they put all the sound files for a given activity in a single folder (likely to be downloaded at the same time by all the students in a class). If only one class uses the activity, that's less than 30 downloads, it shouldn't bug. If 2 or more classes are involved in the activities, there could be problems again... But it is already the beginning of a solution...

This is all you need:

Try this one:

OK
Thank You
Is it this one?

Or try this

intDownload.aia (4.9 KB)

I have used images instead of mp3s, but the premise is the same.

View the first few images, then refresh the companion, you should not see the progress dialog until you reach a new file when you start viewing again. Once you have all the files then they view more or less immediately.

Here also is a short google apps script, bound to a google sheet, that writes file details to a google sheet:

function getFileIdAndNames() {

 var FileFolderID = 'YOUR FOLDER ID HERE'; // the ID of the folder with files
 var ss = SpreadsheetApp.getActiveSpreadsheet();
 var sheet = ss.getSheets()[0];
 var urlCol = 1;
 var urlRow = 1;
 var folder = DriveApp.getFolderById(FileFolderID);
 var files = folder.getFiles();

 sheet.clear();

 while (files.hasNext()) {
 var file = files.next();
 
 
   if (file.getName().indexOf(".png") != -1) {
     sheet.getRange(urlRow, urlCol).setValue(file.getName());
     sheet.getRange(urlRow, urlCol+1).setValue(file.getId());
     sheet.getRange(urlRow, urlCol+2).setValue('https://drive.google.com/uc?export=download&id='+ file.getId());
     sheet.getRange(urlRow, urlCol+3).setValue('PNG');
     sheet.getRange(urlRow, urlCol+4).setValue(Math.round(file.getSize()/1000) + " KB");
     sheet.getRange(urlRow, urlCol+5).setValue(file.getName().substr(7).slice(0, -4));
   } 
   
 urlRow = urlRow+1;
 }
  sheet.sort(1, true);
  sheet.sort(4, true);
  sheet.insertRows(1);
  var title = [["Filename","File ID","Direct Link to Download","File Type","File Size (KB)","Description"]];
  var fontStyles = [ [ "bold", "bold", "bold", "bold", "bold","bold" ]];
  var titleRange = sheet.getRange("A1:F1");
  titleRange.setValues(title);
  titleRange.setFontWeights(fontStyles);
 }

Output:

Does the APK work for you?

Yes, it works. Although I still have a little trouble understanding the code. THANKS.
The proposal also works well with images. Thanks, it's good for the test application.

However, teachers will use a slightly different program.

Description of typical use:
1- A teacher creates an .mp3 file containing a word that corresponds to an image.
2- The teacher places this .mp3 file on his Google Drive (in a folder shared with anyone who has the link)
3- It retrieves the sharing link of this .mp3 file.
4- It uses a small application (that I programmed in python) which generates a QR code containing the Google Drive ID of the file.
5- He pastes this QR code into his document (created with Libre Office for example), next to an image which corresponds to the word contained in the .mp3.
6- He prints this document for his students.
7- The student uses the application on his parents' phone at home: he scans the QR code created by the teacher: he listens to the word corresponding to the image.

The teacher should be able to create, for example, a notebook with 30 images associated with 30 QR codes giving links to the corresponding sounds...
But if his 25 students, returning home at the same time, start their homework around the same time, well it's over: we explode the 40 downloads in 10 minutes (approximately...)

What could smooth things out a bit is a single download of the folder containing the audios in a single .zip

Example :
1- The Android application detects the name of the file (on GD) which is requested for reading.
2- It detects in its local memory if it already has the requested file.
3- If not, it detects the parent folder which contains the mp3 file on GD.
4- It downloads this entire folder in a single ZIP (a single download).
5- It unzips the archive into a local folder.
6- The Android app finds the requested file in this unzipped folder.
7- The Android app reads it.

But I think I understand that neither of those two proposals uses a similar procedure.

That is quite different from what we have been looking at....

Does the qrcode have to be created? then printed ?

This could all happen on the students phone.....

No, it's no different from the test application I presented to you...
The whole party:

  • creation of QR codes from the file ID,
  • scanning QR codes by phone,
  • listening to the .mp3 by correspondent on the student's phone...
    It all already works very well. I have already developed it...

But last Wednesday, when I gave the kids an activity that had lots of threads instead of just a poetry text, the number of downloads to my Drive increased and the bug was revealed...
I looked for a solution on my own, first. I managed to isolate the bug and understand that it came from the mp3 files, not the QR codes or the reading module (Player or Taifun Player...)

So I developed this little test application so that you can reproduce the bug at home.

But it's the same. This is just so you understand the importance of being able to download a file in one go.

:question:

clearly not.....

Do not make fun of me :sweat_smile:

  • Creation of QR codes from the file ID --> Working: already in use ("MAEL Gen" is a standalone application in Python. Some colleagues and I use it every day)
    Avec balise gd

  • Scanning QR codes by phone --> Working: already in use ("MAEL Scan" is the Android application that my students have been using since the beginning of September.)

  • Listening to the .mp3 on the phone... --> Works if there are relatively few downloads... (This is the problem of MAEL Scan, concentrated in this test application)

But this problem is crippling...
That's why I came for help. At first, I thought it was a file management problem (hence the name of the post: "Mysterious file management") But thanks to you, I understood that the problem was actually in the download.

I already have hundreds of hours of programming on this project... Now I'm looking for a workaround since it seems like the issue is not in my App Inventor code...

Have you considered using TextToSpeech ? This would remove most of the actions in the above?

intDownloadWithTTS.aia (5.7 KB)

Yes, this is the first function that I implemented. But to say single syllable (TTS is bad at it), a poetry expressively or a story readings, I had to add the possibility of reading .mp3 files online.

I improvised "tags" which are incorporated into the QR code (by "MAEL Gen") to indicate to "MAEL Scan" if it is a text to be spoken by TTS (and in what language), or if it is an .mp3 file to read from a GD.

At the moment, the only other option I can think of, aside from not using google drive, is to use a google apps script to download the audio files as base64 then convert them back to binary in the app (or play them as datauris in a webviewer)

If you have your own/schools online server, you / others could upload your files with ftp or through a web interface and get the urls that way

Going back to @Anke's suggestion for downloading all files in a zip, here is an AI2 solution to generating a zip on google drive and downloading and unzipping the files (uses @Taifun's zip extension)

Here are some tips which probably can help

Taifun

Thank you so much!
I'm going to study that.