How to Fix uni‑app iOS/Android Local Video Upload Failures

This guide explains why video recordings that upload correctly on a real device can fail after TestFlight or cloud packaging, detailing the mismatched file‑system paths between plus.io, iOS Documents/Library, and Android Movies directories, and provides step‑by‑step fixes to ensure reliable uploads to Alibaba Cloud VOD.

liandk
liandk
liandk
How to Fix uni‑app iOS/Android Local Video Upload Failures

1. Path Mapping Overview

plus.io’s _doc directory differs between environments: in HBuilderX real‑device debugging it resides under Documents/Pandora/apps/<appid>/doc, while in TestFlight/IPA builds it moves to Library/Pandora/apps/<appid>/doc. Android writes recordings by default to the app’s Movies folder, which is not under _doc.

iOS debug: Documents/Pandora/apps/<appid>/doc iOS TestFlight: Library/Pandora/apps/<appid>/doc Android:

file:///storage/emulated/0/Android/data/.../Movies/wj-uts-video-recorder/xxx.mp4

2. How the Problem Appears

On a real device the flow

UTS native recording → mp4 generation → plus.io read file → Alibaba Cloud VOD upload

works. The same code built for TestFlight reports “file not found”. The root cause is that the native code writes to the Documents directory, but plus.io expects files under _doc, which in packaged builds lives in Library, causing the upload to look in the wrong place.

3. Common Pitfalls Encountered

Scanning only Documents/Pandora.

When the file is not found, writing it to the Documents root.

Uploading using a fabricated path _doc/wj-uts-video-recorder/xxx.mp4.

Because the debug base happens to place _doc under Documents, the real‑device test passes, but the packaged app’s _doc is under Library, so the upload fails.

4. Mistakes Tried and Their Outcomes

Force writing to Library _doc – fixes TestFlight but breaks real‑device.

Using FileReader.readAsDataURL – the file exists but the read crashes; the correct approach is to let renderjs read the file via plus.io.

Changing setOptions to nine parameters – triggers “unimoduleWjUtsVideoRecorder.framework is missing its bundle executable”. The directory must be set with setDocDir while keeping setOptions at eight parameters.

Unifying iOS Documents and upload path to _documents – plus.io cannot parse _documents, causing both environments to fail.

Changing all paths to _doc/… – fixes iOS, but Android still looks for files in Movies while the upload code searches _doc, resulting in “path does not exist”.

5. Final Solution (by link)

5.1 Before Recording

Query the runtime for the actual _doc location with plus.io.convertLocalFileSystemURL("_doc/"), pass the resolved directory to native code, and wait for the directory to be ready using $nextTick before starting recording.

5.2 iOS Write Strategy

Prefer the _doc path supplied by JavaScript (most accurate). If Pandora already exists, use the existing Documents then Library hierarchy without creating a new fake directory. Always upload using the fixed path _doc/wj-uts-video-recorder/filename.mp4. Do not write to the Documents root and pretend it is _doc.

5.3 Android Write Strategy

If a docDir is provided, write into _doc.

Otherwise keep the native Movies/wj-uts-video-recorder location.

Upload using the absolute file:// path; do not convert it to _doc.

5.4 Upload Handling

Use toPlusIoRelativePath() to generate platform‑specific relative paths:

iOS → _doc/wj-uts-video-recorder/xxx.mp4 Android → file://… + absolute path

On the upload page, try the original path, then file://, then _doc, then PRIVATE_DOC until the file opens. Perform file reading in renderjs, not in the logic layer.

6. Error Reference

“File not found / video file not found” – the write directory and plus.io _doc differ.

“Failed to read video file” – path is correct but FileReader crashes.

“Path does not exist” – usually Android path was mistakenly changed to _doc.

“framework is missing its bundle executable” – setOptions parameters were altered incorrectly.

7. Release Checklist

After fixing Swift/Kotlin/UTS code, a hot‑update of JS alone is insufficient.

iOS:

Uninstall the old debug base.

Delete unpackage/cache/uts_standard_ios.

Re‑create the custom debug base.

Verify upload on a real device.

Re‑package IPA for TestFlight (the old package still contains wrong path logic).

Android:

Standard real‑device runs usually recompile plugins.

Custom base also needs to be rebuilt.

Validate in order: iOS real device → TestFlight → Android real device, fixing one side only after the other passes, to avoid fixing A while breaking B.

8. Core Principles

Write files to the same sandbox that will read them; upload must use the current runtime’s _doc (Android uses file://).

Never hard‑code Documents or Library; always resolve with convertLocalFileSystemURL("_doc/").

Upload paths must be readable by plus.io.

Do not add extra parameters to native interfaces; use setDocDir for custom directories.

Changing native code requires rebuilding the base; debugging success does not guarantee packaged success.

In short, video upload fails not because the file is missing on the device, but because the file is not located in a folder that plus.io can see during the current runtime.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

iOSAndroidvideo uploaduni-appfile pathplus.io
liandk
Written by

liandk

Seasoned Java and mobile developer with years of experience, specializing in mini‑programs, public accounts, and full‑stack front‑end development. In the AI era, I continuously learn to broaden my knowledge and evolve. I revived a public account I started a decade ago during a dessert‑startup venture, using code as a vessel and knowledge as a companion. I share personal projects, technical articles, programming tips, and growth insights—let’s improve together and set sail.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.