Front: remove file64 dependency
This commit is contained in:
committed by
Clément Le Bihan
parent
e0f2674811
commit
8ab85ab689
@@ -21,7 +21,7 @@ import { PlageHandler } from './models/Plage';
|
||||
import { ListHandler } from './models/List';
|
||||
import { AccessTokenResponseHandler } from './models/AccessTokenResponse';
|
||||
import * as yup from 'yup';
|
||||
import { base64ToBlob } from 'file64';
|
||||
import { base64ToBlob } from './utils/base64ToBlob';
|
||||
import { ImagePickerAsset } from 'expo-image-picker';
|
||||
|
||||
type AuthenticationInput = { username: string; password: string };
|
||||
|
||||
@@ -40,7 +40,6 @@
|
||||
"expo-secure-store": "~12.0.0",
|
||||
"expo-splash-screen": "~0.17.5",
|
||||
"expo-status-bar": "~1.4.2",
|
||||
"file64": "^1.0.2",
|
||||
"format-duration": "^2.0.0",
|
||||
"i18next": "^21.8.16",
|
||||
"install": "^0.13.0",
|
||||
|
||||
23
front/utils/base64ToBlob.ts
Normal file
23
front/utils/base64ToBlob.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
// SRC: https://github.com/encrypit/file64/blob/master/src/base64-to-blob.ts
|
||||
export async function base64ToBlob(base64: string): Promise<Blob> {
|
||||
const response = await fetch(base64);
|
||||
let blob = await response.blob();
|
||||
const mimeType = getMimeType(base64);
|
||||
if (mimeType) {
|
||||
// https://stackoverflow.com/a/50875615
|
||||
blob = blob.slice(0, blob.size, mimeType);
|
||||
}
|
||||
return blob;
|
||||
}
|
||||
|
||||
const mimeRegex = /^data:(.+);base64,/;
|
||||
|
||||
/**
|
||||
* Gets MIME type from Base64.
|
||||
*
|
||||
* @param base64 - Base64.
|
||||
* @returns - MIME type.
|
||||
*/
|
||||
function getMimeType(base64: string) {
|
||||
return base64.match(mimeRegex)?.slice(1, 2).pop();
|
||||
}
|
||||
@@ -9451,11 +9451,6 @@ file-uri-to-path@1.0.0:
|
||||
resolved "https://registry.yarnpkg.com/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz#553a7b8446ff6f684359c445f1e37a05dacc33dd"
|
||||
integrity sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==
|
||||
|
||||
file64@^1.0.2:
|
||||
version "1.0.2"
|
||||
resolved "https://registry.yarnpkg.com/file64/-/file64-1.0.2.tgz#d3dde9bab142ccf0049e0bd407a2576e94894825"
|
||||
integrity sha512-cDQefGBdb8OO7Pb2nXiRcZlVjwgzoG0uuJ/H2fxNdz3vbOZctp0iPJoHDQ4VZrirqGYc9n/p9+ZqptLZrcSGRA==
|
||||
|
||||
filesize@6.1.0:
|
||||
version "6.1.0"
|
||||
resolved "https://registry.yarnpkg.com/filesize/-/filesize-6.1.0.tgz#e81bdaa780e2451d714d71c0d7a4f3238d37ad00"
|
||||
|
||||
Reference in New Issue
Block a user