Remove dup

This commit is contained in:
Manav Rathi 2024-04-14 20:07:17 +05:30
parent d0ac3ea9ca
commit 87077417a2
No known key found for this signature in database
2 changed files with 3 additions and 16 deletions

View file

@ -1,3 +1,4 @@
import { nameAndExtension } from "@/next/file";
import log from "@/next/log";
import { CustomError } from "@ente/shared/error";
import { FILE_TYPE } from "constants/file";
@ -7,7 +8,6 @@ import {
} from "constants/upload";
import FileType from "file-type";
import { FileTypeInfo } from "types/upload";
import { getFileExtension } from "utils/file";
import { getUint8ArrayView } from "./readerService";
const TYPE_VIDEO = "video";
@ -40,7 +40,8 @@ export async function getFileType(receivedFile: File): Promise<FileTypeInfo> {
mimeType: typeResult.mime,
};
} catch (e) {
const fileFormat = getFileExtension(receivedFile.name);
const ne = nameAndExtension(receivedFile.name);
const fileFormat = ne[1].toLowerCase();
const whiteListedFormat = WHITELISTED_FILE_FORMATS.find(
(a) => a.exactType === fileFormat,
);

View file

@ -97,20 +97,6 @@ export function getFileExtensionWithDot(filename: string) {
else return filename.slice(lastDotPosition);
}
export function splitFilenameAndExtension(filename: string): [string, string] {
const lastDotPosition = filename.lastIndexOf(".");
if (lastDotPosition === -1) return [filename, null];
else
return [
filename.slice(0, lastDotPosition),
filename.slice(lastDotPosition + 1),
];
}
export function getFileExtension(filename: string) {
return splitFilenameAndExtension(filename)[1]?.toLocaleLowerCase();
}
export function generateStreamFromArrayBuffer(data: Uint8Array) {
return new ReadableStream({
async start(controller: ReadableStreamDefaultController) {