diff --git a/src/components/import/ImportSingleFile.tsx b/src/components/import/ImportSingleFile.tsx index 831ec37..66d0566 100644 --- a/src/components/import/ImportSingleFile.tsx +++ b/src/components/import/ImportSingleFile.tsx @@ -19,6 +19,7 @@ import { Filesystem as CapacitorFileSystem, Encoding, } from '@capacitor/filesystem'; +import ExifReader from 'exifreader'; interface Props { file: File; @@ -84,21 +85,42 @@ const ImportSingleFile: Component = ({ file: file }) => { parseGpx(content.data); }); } else { - const gpxReader = new FileReader(); - gpxReader.readAsText(file); - gpxReader.addEventListener( - 'load', - async () => { - // this will then display a text gpxfile - console.log({ - caller: 'ImportSingleFile / XML', - gpxFile: file, - result: gpxReader.result, - }); - parseGpx(gpxReader.result); - }, - false - ); + const reader = new FileReader(); + if (file.type === 'image/jpeg') { + reader.readAsArrayBuffer(file); + reader.addEventListener( + 'load', + async () => { + // this will then display a text gpxfile + const tags = ExifReader.load(reader.result); + console.log({ + caller: 'ImportSingleFile / Jpeg', + file, + type: file.type, + result: reader.result, + tags, + }); + //parseGpx(reader.result); + }, + false + ); + } else { + reader.readAsText(file); + reader.addEventListener( + 'load', + async () => { + // this will then display a text gpxfile + console.log({ + caller: 'ImportSingleFile / XML', + file, + type: file.type, + result: reader.result, + }); + parseGpx(reader.result); + }, + false + ); + } } const doImport = async () => { setState('importing'); @@ -113,9 +135,9 @@ const ImportSingleFile: Component = ({ file: file }) => { tech: typeof file === 'string' ? { - importDate: new Date().toISOString(), + importDate: new Date().toISOString(), uri: file, - } + } : { lastModified: new Date(file.lastModified).toISOString(), importDate: new Date().toISOString(),