fix(scan): timeout i uploadImage + rätt API_BASE_URL så mock-upload når telefonen (MIKRO 51)
CI / Typecheck, test & build (push) Successful in 1m36s
CI / Typecheck, test & build (push) Successful in 1m36s
This commit is contained in:
@@ -99,12 +99,28 @@ export async function uploadImage(
|
|||||||
localUri: string,
|
localUri: string,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const blob = await (await fetch(localUri)).blob();
|
const blob = await (await fetch(localUri)).blob();
|
||||||
const res = await fetch(upload.uploadUrl, {
|
const controller = new AbortController();
|
||||||
method: "PUT",
|
const timer = setTimeout(() => controller.abort(), 30000);
|
||||||
headers: upload.headers,
|
try {
|
||||||
body: blob,
|
const res = await fetch(upload.uploadUrl, {
|
||||||
});
|
method: "PUT",
|
||||||
if (!res.ok) throw new ApiError(res.status, "UPLOAD_FAILED", "Bilduppladdningen misslyckades.");
|
headers: upload.headers,
|
||||||
|
body: blob,
|
||||||
|
signal: controller.signal,
|
||||||
|
});
|
||||||
|
if (!res.ok) throw new ApiError(res.status, "UPLOAD_FAILED", "Bilduppladdningen misslyckades.");
|
||||||
|
} catch (err) {
|
||||||
|
if (err instanceof Error && err.name === "AbortError") {
|
||||||
|
throw new ApiError(
|
||||||
|
0,
|
||||||
|
"UPLOAD_TIMEOUT",
|
||||||
|
"Uppladdningen tog för lång tid – kontrollera nätverket och försök igen.",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
throw err;
|
||||||
|
} finally {
|
||||||
|
clearTimeout(timer);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ConsentStatus {
|
export interface ConsentStatus {
|
||||||
|
|||||||
Reference in New Issue
Block a user