Skip to content

best way to save what you love

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

wukko46c5e2e2b520
diff --git a/web/src/lib/download.ts b/web/src/lib/download.ts
index 4ef33195..393b8e82 100644
--- a/web/src/lib/download.ts
+++ b/web/src/lib/download.ts
@@ -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") {