feat: get mime from library that checks the file binary

This commit is contained in:
Zamitto 2024-06-19 15:33:24 -03:00
parent 17cfc7bb02
commit 887d97fd20
3 changed files with 13 additions and 9 deletions

View file

@ -3,7 +3,7 @@ import { HydraApi } from "@main/services/hydra-api";
import axios from "axios";
import fs from "node:fs";
import path from "node:path";
import mime from "mime";
import { fileTypeFromFile } from "file-type";
import { UserProfile } from "@types";
const patchUserProfile = async (
@ -44,11 +44,11 @@ const updateProfile = async (
.then(async (preSignedResponse) => {
const { presignedUrl, profileImageUrl } = preSignedResponse.data;
const mimeType = mime.getType(newProfileImagePath);
const mimeType = await fileTypeFromFile(newProfileImagePath);
await axios.put(presignedUrl, fileBuffer, {
headers: {
"Content-Type": mimeType,
"Content-Type": mimeType?.mime,
},
});
return profileImageUrl;