|
|
|
@ -99,7 +99,13 @@ export const getMimeType = async input => {
|
|
|
|
|
type = _getMimeType(input);
|
|
|
|
|
|
|
|
|
|
if (!type) {
|
|
|
|
|
type = await get(input).then(res => res.blob().then(blob => blob.type));
|
|
|
|
|
const response = await get(input);
|
|
|
|
|
const blob = await response?.blob?.();
|
|
|
|
|
if (!blob) {
|
|
|
|
|
type = response?.headers?.['content-type']?.split(';')[0];
|
|
|
|
|
} else {
|
|
|
|
|
type = blob?.type;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!type) {
|
|
|
|
@ -139,7 +145,7 @@ export const removeDirRecursive = async directory => {
|
|
|
|
|
export const getMediaDimensions = async (url, mimeType) => {
|
|
|
|
|
mimeType = mimeType || await this.getMimeType(url);
|
|
|
|
|
// Check if it's an image
|
|
|
|
|
if (mimeType.split('/')[0] === 'image') {
|
|
|
|
|
if (mimeType?.split('/')[0] === 'image') {
|
|
|
|
|
// If it's a file, we'll use the image-size package
|
|
|
|
|
if (existsSync(url) && lstatSync(url).isFile()) {
|
|
|
|
|
return new Promise(resolved => {
|
|
|
|
@ -152,7 +158,7 @@ export const getMediaDimensions = async (url, mimeType) => {
|
|
|
|
|
img.src = url;
|
|
|
|
|
});
|
|
|
|
|
// Check if it's a video
|
|
|
|
|
} else if (mimeType.split('/')[0] === 'video') {
|
|
|
|
|
} else if (mimeType?.split('/')[0] === 'video') {
|
|
|
|
|
return new Promise(resolve => {
|
|
|
|
|
const video = document.createElement('video');
|
|
|
|
|
video.src = url;
|
|
|
|
|