commit
03595c6888
|
@ -31,9 +31,14 @@ export async function getExifData(
|
|||
receivedFile: globalThis.File,
|
||||
fileTypeInfo: FileTypeInfo
|
||||
): Promise<ParsedEXIFData> {
|
||||
const nullExifData: ParsedEXIFData = {
|
||||
location: NULL_LOCATION,
|
||||
creationTime: null,
|
||||
};
|
||||
try {
|
||||
const exifData = await getRawExif(receivedFile, fileTypeInfo);
|
||||
if (!exifData) {
|
||||
return { location: NULL_LOCATION, creationTime: null };
|
||||
return nullExifData;
|
||||
}
|
||||
const parsedEXIFData = {
|
||||
location: getEXIFLocation(exifData),
|
||||
|
@ -44,6 +49,10 @@ export async function getExifData(
|
|||
),
|
||||
};
|
||||
return parsedEXIFData;
|
||||
} catch (e) {
|
||||
logError(e, 'getExifData failed');
|
||||
return nullExifData;
|
||||
}
|
||||
}
|
||||
|
||||
export async function getRawExif(
|
||||
|
@ -63,6 +72,7 @@ export async function getRawExif(
|
|||
}
|
||||
|
||||
export function getUNIXTime(dateTime: Date) {
|
||||
try {
|
||||
if (!dateTime) {
|
||||
return null;
|
||||
}
|
||||
|
@ -72,6 +82,9 @@ export function getUNIXTime(dateTime: Date) {
|
|||
} else {
|
||||
return unixTime;
|
||||
}
|
||||
} catch (e) {
|
||||
logError(e, 'getUNIXTime failed', { dateTime });
|
||||
}
|
||||
}
|
||||
|
||||
function getEXIFLocation(exifData): Location {
|
||||
|
|
Loading…
Reference in a new issue