Read release metadata from the APK
OrangeVPN's Android upload workflow handles two pieces of release data that can get out of sync. An operator enters a version in the release editor, while Android reads the package and version from the APK itself. A file name can look correct even when it points to an older build. If the upload workflow trusts the name or the form alone, an update screen can announce a version the download will never install.
The upload code compares the APK's version name and numeric version code with the release record before it accepts the pairing. It reports the values read from the file when they differ. That gives the operator a choice between selecting the intended build and correcting the release form. The numeric version code controls Android's update ordering, while the version name is what users normally see.
Copy, verify, then publish
The storage code streams the APK to a temporary file in the destination directory. It compares the stored byte count and SHA-256 digest with the metadata collected before the copy. Only then does it rename the temporary file to its final APK name. A failed copy stays outside the normal download path and is cleaned up, which avoids exposing a half-written APK when an upload is interrupted.
A checksum comparison verifies that the stored bytes match the submitted bytes. Android's signing checks answer a different question. Keep the signing key consistent for updates and validate the signing identity as part of release verification. A correct version and checksum alone do not tell you that Android will accept the file as an update.
Keep upload state separate from release state
The workflow records an upload receipt before handing back the download URL. The receipt marks the file as awaiting the release save, which lets the operator distinguish a successful file transfer from a published update. Treating those as separate states also makes retries easier. After an uncertain save, read back the release record before re-uploading or removing a file.
Rehearse with a test release
- Choose an APK and deliberately enter a different version code in a test release. Confirm that the workflow catches the mismatch before publishing.
- Upload the matching file. Download it from the test URL and compare its SHA-256 digest with the original APK.
- Install it over a previously signed test build. Confirm that Android accepts the update and that the app still opens with its local data.
- Read back the update metadata through the path the app uses and confirm that the version, download URL and file all refer to the same release.
The final install check catches errors that a web upload alone cannot reveal. See Android's versioning guide and its app signing guide for the platform rules.