mirror of
https://github.com/immich-app/immich.git
synced 2025-01-07 20:36:48 +01:00
fix(web): use server api media types (#3687)
This commit is contained in:
parent
67bac9ff59
commit
079aa13edb
1 changed files with 13 additions and 49 deletions
|
@ -1,62 +1,25 @@
|
||||||
import { uploadAssetsStore } from '$lib/stores/upload';
|
import { uploadAssetsStore } from '$lib/stores/upload';
|
||||||
import { addAssetsToAlbum } from '$lib/utils/asset-utils';
|
import { addAssetsToAlbum } from '$lib/utils/asset-utils';
|
||||||
import type { AssetFileUploadResponseDto } from '@api';
|
import { api, AssetFileUploadResponseDto } from '@api';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import { notificationController, NotificationType } from './../components/shared-components/notification/notification';
|
import { notificationController, NotificationType } from './../components/shared-components/notification/notification';
|
||||||
|
|
||||||
const extensions = [
|
let _extensions: string[];
|
||||||
'.3fr',
|
|
||||||
'.3gp',
|
const getExtensions = async () => {
|
||||||
'.ari',
|
if (!_extensions) {
|
||||||
'.arw',
|
const { data } = await api.serverInfoApi.getSupportedMediaTypes();
|
||||||
'.avi',
|
_extensions = [...data.image, ...data.video];
|
||||||
'.avif',
|
}
|
||||||
'.cap',
|
return _extensions;
|
||||||
'.cin',
|
};
|
||||||
'.cr2',
|
|
||||||
'.cr3',
|
|
||||||
'.crw',
|
|
||||||
'.dcr',
|
|
||||||
'.dng',
|
|
||||||
'.erf',
|
|
||||||
'.fff',
|
|
||||||
'.flv',
|
|
||||||
'.gif',
|
|
||||||
'.heic',
|
|
||||||
'.heif',
|
|
||||||
'.iiq',
|
|
||||||
'.jpeg',
|
|
||||||
'.jpg',
|
|
||||||
'.k25',
|
|
||||||
'.kdc',
|
|
||||||
'.mkv',
|
|
||||||
'.mov',
|
|
||||||
'.mp2t',
|
|
||||||
'.mp4',
|
|
||||||
'.mpeg',
|
|
||||||
'.mrw',
|
|
||||||
'.nef',
|
|
||||||
'.orf',
|
|
||||||
'.ori',
|
|
||||||
'.pef',
|
|
||||||
'.png',
|
|
||||||
'.raf',
|
|
||||||
'.raw',
|
|
||||||
'.rwl',
|
|
||||||
'.sr2',
|
|
||||||
'.srf',
|
|
||||||
'.srw',
|
|
||||||
'.tiff',
|
|
||||||
'.webm',
|
|
||||||
'.webp',
|
|
||||||
'.wmv',
|
|
||||||
'.x3f',
|
|
||||||
];
|
|
||||||
|
|
||||||
export const openFileUploadDialog = async (
|
export const openFileUploadDialog = async (
|
||||||
albumId: string | undefined = undefined,
|
albumId: string | undefined = undefined,
|
||||||
sharedKey: string | undefined = undefined,
|
sharedKey: string | undefined = undefined,
|
||||||
) => {
|
) => {
|
||||||
|
const extensions = await getExtensions();
|
||||||
|
|
||||||
return new Promise<(string | undefined)[]>((resolve, reject) => {
|
return new Promise<(string | undefined)[]>((resolve, reject) => {
|
||||||
try {
|
try {
|
||||||
const fileSelector = document.createElement('input');
|
const fileSelector = document.createElement('input');
|
||||||
|
@ -87,6 +50,7 @@ export const fileUploadHandler = async (
|
||||||
albumId: string | undefined = undefined,
|
albumId: string | undefined = undefined,
|
||||||
sharedKey: string | undefined = undefined,
|
sharedKey: string | undefined = undefined,
|
||||||
) => {
|
) => {
|
||||||
|
const extensions = await getExtensions();
|
||||||
const iterable = {
|
const iterable = {
|
||||||
files: files.filter((file) => extensions.some((ext) => file.name.toLowerCase().endsWith(ext)))[Symbol.iterator](),
|
files: files.filter((file) => extensions.some((ext) => file.name.toLowerCase().endsWith(ext)))[Symbol.iterator](),
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue