From 00a57df5b16bc946c50079914962cc2819011e80 Mon Sep 17 00:00:00 2001 From: Matthieu Sieben Date: Sun, 12 May 2024 23:18:42 +0200 Subject: ✅ Fix "Download CAR file" on mobile (#3816) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * download CAR file using AtpAgent instead of building URL * add loader icon on download car button * actually save to disk on android * style nits * bottom margin nit * localize toast * remove fallback so back button works correctly * keep throwing an error if mime type isn't used * be more explicit with toasts * send errors to sentry when encountered --------- Co-authored-by: Hailey --- src/lib/api/api-polyfill.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/lib/api/api-polyfill.ts') diff --git a/src/lib/api/api-polyfill.ts b/src/lib/api/api-polyfill.ts index ea1d97598..e3aec7631 100644 --- a/src/lib/api/api-polyfill.ts +++ b/src/lib/api/api-polyfill.ts @@ -1,5 +1,5 @@ -import {BskyAgent, stringifyLex, jsonToLex} from '@atproto/api' import RNFS from 'react-native-fs' +import {BskyAgent, jsonToLex, stringifyLex} from '@atproto/api' const GET_TIMEOUT = 15e3 // 15s const POST_TIMEOUT = 60e3 // 60s @@ -68,8 +68,10 @@ async function fetchHandler( resBody = jsonToLex(await res.json()) } else if (resMimeType.startsWith('text/')) { resBody = await res.text() + } else if (resMimeType === 'application/vnd.ipld.car') { + resBody = await res.arrayBuffer() } else { - throw new Error('TODO: non-textual response body') + throw new Error('Non-supported mime type') } } -- cgit 1.4.1