Error while copying a file from assets to device

Hello! :slight_smile:

I’m trying to copy a file from my app assets, but it is no working.

Whenever I try to copy it, I always get the message: “Sorry, file to copy does not exist”.

I’m using Taifun’s extension to copy the file.

I’ve been reading the forum (and App Inventor Extensions: File | Pura Vida Apps) and I can’t understand why it’s not working.

To be sure that I’m not doing anything silly (like typos), I’m using the file testCopyDelete.aia provided by Taifun. :slight_smile:

My screen:

My assets:

My blocks:

My phone’s screen when I click the button:

As you can see, I got that error saying that the file doesn’t exist.

I don’t know if it’s important, but I’m using a Moto G phone.

I’ll leave here the AIA file as well. If someone could help me, I will be forever grateful! :smiley:

Test_forum.aia (41.5 KB)

Thanks!

1 Like

Nope, the text formatting isn’t correct. You should do:

/storage/emulated/0/{folder}/WooHoo.pdf

1 Like

Hi!

Are talking about the toFileName area?
Thanks, but my problem is that I can’t even copy the file from the assets folder. :frowning:

Yes. Try first downloading the asset the copying it?

Are you using the companion or an apk ?

1 Like

Well, Taifun’s text says that it works with the companion:

“… To copy assets packaged with an application (also works for the Companion) start the fromFilename with // (two slashes)…”

But no problem, I’ll try your idea! Just give me one minute! :slight_smile:

1 Like

Nope. Even with the apk it’s not working. :frowning:

Could you, please, try my AIA file and test if it’s working?

I’m on it :slight_smile:

1 Like

Did my answer work?

I’m sorry, could you say again? I didn’t get your ideia.:slightly_smiling_face:

So, you want to copy an asset that is in your project file? (AIA)

1 Like

As @Mateja the path is wrong, I’ve tested with the companion and it works fine.

Of course, when you use an apk the path is different…

1 Like

Yes, that’s it. I want to copy a file (mp3) when the user clicks the button.

But I always get the error saying that the original file wasn’t found (even that it IS in the assets folder).

Okay. But if the user runs the app via the companion, you need to put the toFileName text to:

/storage/emulated/0/Makeroid/{name of the file with format example: lol.mp3}

or

/Makeroid/assets/file

Why? Because when connecting to the companion the console or whatever sends all the assets to the companion (your phone)


If the user is running the app from an installed APK file (everything else except the companion) then you first need to download the file from a website to the users phone using the Download component. Example:


How I got the https://bit.ly/testkdlr link. It is a direct download link, if you click it, you will instantly download a picture:

  1. Upload your file to MediaFire
  2. Open the link
  3. Right click download, copy link location.
1 Like

How about updating the extension, your test aia has version 2, newest version is 11

/Boban

1 Like

And use this block

Test_forum_copy.aia (59.9 KB)

/Boban

1 Like

Well, that is quite a surprise!

I get this extension from App Inventor Extensions: File | Pura Vida Apps

So, could you tell me where I can get the version 11?

I just downloaded it myself as I had version 10 and yes that’s the link

In Kodular check your extension version

bild

/Boban

2 Likes

Well, it worked. But this Makeroid folder is a folder created by the
Companion, right?

When I export the APK and sent it to someone else (who doesn’t have that folder), it won’t work, am I right?

As Ontstudios stated, I will need to download the mp3 from the internet first?

Hmmm, I understand your whole idea, but wasn’t the Taifun’s extension created exactly to do that? I mean, with this extension, we would be able to download files from the apk assets, right?