taifun file extensio: copy doesn't work

235 views
Skip to first unread message

Harry van der Wolf

unread,
Apr 21, 2017, 9:06:52 AM4/21/17
to MIT App Inventor Forum
Hi,

I tried the Taifun file extension which seems a great extension. I downloaded the extension on 20 April 2017.
My phone is a Samsung S5 mini running stock android 6.01

I embedded it in one of my projects where I first used the invisible file component as filereader to read a file and save it again.
The file extensions does this more elegantly.
However, it didn't work. I got the error "Sorry, file to copy does not exist."

I only use(d) compiled apks. I did not use the AI companion (w.r.t mentioned bugs in the companion and w.r.t. the "file:///android_asset" file path.)

As my already long existing project is rather complicated, I stopped that one for testing.
I created a super simple app that first contained the first 2 blocks, but that didn't work.
So I added a listpicker and let the elements be filled with "call Taifunfile1.AvaliableStoragedirectories.

That gave me the following available folders:
/storage/9016-4EF8/
/storage/emulated/0/

The first is me external SDcard, the second my internal memory.
So, i simply added them (block 3 and 4). I already did read that you can only write to external sdcard to the apps own folder, but I simply didn't understand the error message "Sorry, file to copy does not exist.", so I left the path on the ext sdcard for what it was.

As you can see from my screen capture the file jetscript.sh is in my project.
I also used the "apktool d" command to decompile my apk and my jetscript.sh was indeed in my assets folder (like the com.puravidaapps.TaifunFile extension).

Why do I get the  "Sorry, file to copy does not exist." error. Is it a bug or am I doing something wrong?


Harry van der Wolf

unread,
Apr 21, 2017, 9:26:23 AM4/21/17
to MIT App Inventor Forum
After a struggle of 2 hours or so, I simply did use the emulator and changed the paths accordingly.

No, it works: from the emulator.
Of course the 4th block gives an "access denied", but that was an error I expected.

Why does it work from the emulator and not from the apk?

Harry van der Wolf

unread,
Apr 21, 2017, 9:55:50 AM4/21/17
to MIT App Inventor Forum
I seem to be keeping answering my own posts :)

I simply used the paths on the Pura Vida website without further thinking.
It mentioned in the Tutorials "App inventor and embedded html/javascript" section the following:

App Inventor and embedded HTML/JavaScript

Yes, you also can upload html files as assets into App Inventor! There is only one special thing to consider: During development, you have to use the development path to the embedded html document:

file:///mnt/sdcard/AppInventor/assets/<NAME OF YOUR HTML FILE>.html


Before packaging the app, use the production path.

file:///android_asset/<NAME OF YOUR HTML FILE>.html

When the emulator worked I went back to the appinventor reference which mentions to use /somefilte.txt for the internal sdcard, and to use //somefile.txt for readings assets inside your apk.
I switched from "file:///android_asset/jetscript.sh" to "//jetscript.sh" and now the file extension works.

So far so good. Thanks for the marvelous extension :)

Taifun

unread,
Apr 21, 2017, 12:12:03 PM4/21/17
to MIT App Inventor Forum
great, you found out your problem yourself...
also next time you might want to take a look at the documentation https://puravidaapps.com/file.php...

Copy file.
Use this method to copy small files, for large files use the CopyAsync method instead. Prefix the filename with / (i.e. relative path) to copy a file on the SD card. For instance /myFile.txt will copy the file /mnt/sdcard/myFile.txt. To copy assets packaged with an application (also works for the Companion) start the fromFilename with // (two slashes). However you can't copy files to the assets. If a fileName starts with file:/// you can specify a complete path to the file.

I only use(d) compiled apks. I did not use the AI companion (w.r.t mentioned bugs in the companion and w.r.t. the "file:///android_asset" file path.)
you should first test using the companion app, which bug are you talking about?
the path file:///android_asset is only valid for the webviewer after building the app... 

Taifun

Harry van der Wolf

unread,
Apr 22, 2017, 8:42:38 AM4/22/17
to MIT App Inventor Forum
I know the path file:///android_asset/ is only valid for a compiled apk. That's what I mentioned in my first post.
And that was my issue when I wanted to copy a script out of my assets. Your file extension did not recognize that path. That's when I got the error: "Sorry, file to copy does not exist."

Only after I changed the path from file:///android_asset/ to //, the compiled apk with your file extension could copy the file out of my assets.
So I think your file extension has some trouble seeing that file:///android_asset/ and // are indentical.

Taifun

unread,
Apr 22, 2017, 10:58:14 AM4/22/17
to MIT App Inventor Forum
I know the path file:///android_asset/ is only valid for a compiled apk. That's what I mentioned in my first post.
that path is only valid for the webviewer for a compiled apk

Your file extension did not recognize that path. That's when I got the error: "Sorry, file to copy does not exist."
yes, because to access the assets you have to use //, see again the documentation

Only after I changed the path from file:///android_asset/ to //, the compiled apk with your file extension could copy the file out of my assets.
as written in the documentation

So I think your file extension has some trouble seeing that file:///android_asset/ and // are indentical.
see again my answer above and follow the documentation. thank you.
Taifun

Harry van der Wolf

unread,
Apr 23, 2017, 3:48:15 AM4/23/17
to MIT App Inventor Forum
I am grateful for your extension and I didn't want to set this thread in the wrong direction.
I did read your documentation (I even printed it out) and switched back to the //.

My misunderstanding was that // and file://android_asset were simple aliases.
After your answer Yesterday I searched all available documentation: from your site, the reference documentation on the appinventor site, and some google searches.

Maybe I did not search well enough, but nowhere could I find that file://android_asset/ was ONLY for the webviever, and definitely not in the appinventor reference documents. I knew it had to be used for web content specifically, but again: I simply though they were aliases.

I know now and will not make that mistake again, but for me it was the same as file:///storage/emulated/0/ and  file:///mnt/sdcard/

I will send a friendly request to MIT to ask them to put it more clear in their reference documentation.
Reply all
Reply to author
Forward
0 new messages