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