Illegal Character In Path At Index... How to save canvas

Hello, I am trying to save my a canvas I've created in MIT App Inventor straight to the gallery on my Android phone. I understand there is some kind of bug at the moment which prevents this and I have seen similar problems on the forum but I am still unsure how to go about successfully implementing these solutions for the case of the save canvas function. These are are the blocks I currently have implemented in the program to save the canvas:

and this is the error I get:
Illegal character in path at index 81: file:///storage/emulated/0/Android/data/edu.mit.appinventor.aicompanion3/files/My Documents/Pictures/app_inventor_1634978166849.png
Note: You will not see another error reported for 5 seconds.

Thanks in advanced for the help!

The problem arises due to the space in your given file directory (My Documents).
Save it in another directory that doesn't contain a space.
Also, please make sure to search the Community before you post a topic; this bug has been discussed numerous times already:

2 Likes

I see... and thank you very much for the quick response! But how do I remove the space in the My Documents folder?

Apologies for bringing up this problem again on the forums

You can change the directory to another one. Since My Documents is an in-built folder, you cannot change its name.

1 Like

I see. Does that mean it is no longer possible to save the documents to the gallery at all? I have been a long time iphone user and am unfamiliar with how file directories work on android devices I think that is a maybe main cause for my confusion....

Is there an easily accessible directory I can save it to? And how do I go about implementing that in App Inventor.

Thanks again

1 Like

You can save it in one of the Shared folders, e.g.:

  • /Download
  • /Documents
  • /Pictures
    ...

See also here:

2 Likes

Okay thank you for the additional resources.

How do I then save my image it into one of those directories which don't have a space in the title?

1 Like

Can someone please help if they have the solution? I'm sure it is a simple solution but I am struggling to find the answer

This should work for you, it will save the canvas image to the ASD (application specific directory)

image

in companion the path returned is:

file:///storage/emulated/0/Android/data/edu.mit.appinventor.aicompanion3
/files/mycanvas.jpg

in compiled app the path should be

file:///storage/emulated/0/Android/data/<package_name>
/files/mycanvas.jpg

Thanks for the reply! I tried this and although the App gave no errors and seemingly saved the file to the storage location the image was nowhere to be found under the given directory. Searching the phone for the image name also revealed no results :frowning:

At this point I am really unsure of what I could do to try and get this image saving to work and it seems that AppInventor just doesn't allow for this functionality in any accessible way. But if anyone has any further ideas or ways to get this working please let me know!

Post the aia or a test aia.

Working_Device_List.aia (293.8 KB)

Here is my aia. I tried using the full filename as specified by @TIMAI2 but then in this version just used the filename "/mycanvas.jpg". I think this version is correct but maybe I am wrong.

I really appreciate the help and support given with regards to my problem. You guys and girls are heroes

Try this app (save image → ASD):

Screenshot

Is there any chance you could share the .aia file for this app that I could upload to my phone as a .apk? If not I am sure I can get this app on my phone but it would be easier through the .aia

Nevermind it was very easy installing it directly from the .apk

When using this app it appears to save the image but then when I folder dive on the android through storage/emulated/0/android/data/ I do not see the folder which I believe should have been created by the app. Once again doing a deep search of the phone the saved image / file does not come up...

Is this a problem with how I am diving through the android directories? At the end of the day I would also like the files to be saved in an accessible folder for the more novice user

The ASD is no longer visible on Android 11+ devices. Connect you device via USB with your computer and you will see it. Or use a file manager app (e.g. Total Commander) to get access to the ASD. Search the forum, there are a lot of topics on this ...

2 Likes

If that is the case I think I will not try and implement this functionality within my app as it just seems to cumbersome, but thank you so much for the help and I feel satisfied knowing that I really tried to get it to work :slight_smile:

You have not said what it is you want to do with your image once you have created it....

You can save the image (canvas) also in one of the Shared folders (e.g. /Documents /Download, /Pictures or ...):

Set DefaultFileScope to Shared in the Designer.

See also here: