Can't save ParseFile from Uri/java.io.File

If a user selects a video file from their gallery and I try to save a video file using
ParseFile file = new ParseFile(new File(videoUri.getPath()));,
the file.getName() returns something like “video:1000034430” if the uri is “content://com.android.providers.media.documents/document/video%3A1000034430”.

When I try to save the file with file.saveInBackground(...) I get the error “i/o failure” with a status code of 100.

Saving the same video using a byte array (new ParseFile("myfilename.mp4", bytes)) works just fine but this can not be used for large videos (app crashes when it tries to allocate too much memory).

The Javadoc for ParseFile(String name, byte[] data) says “The file name must begin with an alphanumeric character, and consist of alphanumeric characters, periods, spaces, underscores, or dashes” but when using a file Parse uses the file’s name (new State.Builder().name(file.getName())...).

Why is it not possible to set a custom filename when using a java.io.File?

Solved this by copying the file to the cache directory with a filename that works