web/download: use shareFile or openFile depending on file size on ios

This commit is contained in:
wukko 2025-05-19 20:35:42 +06:00
parent 46942a36b3
commit 46c5e2e2b5
No known key found for this signature in database
GPG Key ID: 3E30B3F26C7B4AA2

View File

@ -106,6 +106,20 @@ export const downloadFile = ({ url, file, urlType }: DownloadFileParams) => {
try {
if (file) {
// 256mb cuz ram limit per tab is 384mb,
// and other stuff (such as libav) might have used some ram too
const iosFileShareSizeLimit = 1024 * 1024 * 256;
// this is required because we can't share big files
// on ios due to a very low ram limit
if (device.is.iOS) {
if (file.size < iosFileShareSizeLimit) {
return shareFile(file);
} else {
return openFile(file);
}
}
if (pref === "share" && device.supports.share) {
return shareFile(file);
} else if (pref === "download") {