edit get files extensions query
This commit is contained in:
@@ -2,18 +2,17 @@ import ProtectionSummary from '@/app/ui/marking-page/protection-summary';
|
||||
import FilesTable from '@/app/ui/dashboard/files-table';
|
||||
import PageTitle from '@/app/ui/page-title';
|
||||
import UploadSectionFile from '@/app/components/upload-section-file';
|
||||
import { getAllowedFilesExtensions } from '@/app/actions/file-upload';
|
||||
|
||||
const ALLOWED_EXTENSIONS: string[] = ['jpg', 'jpeg', 'png', 'gif', 'bmp'];
|
||||
const FILE_TYPE = "AUDIO"
|
||||
const MAX_SIZE = 1048576000;
|
||||
|
||||
export default function Page() {
|
||||
export default async function Page() {
|
||||
const FILE_TYPE = "audio";
|
||||
const { file_extension, max_file_size } = await getAllowedFilesExtensions(FILE_TYPE);
|
||||
|
||||
return (
|
||||
<div>
|
||||
<PageTitle title="audio-protection" />
|
||||
<ProtectionSummary />
|
||||
<UploadSectionFile fileType={FILE_TYPE} allowedExtensions={ALLOWED_EXTENSIONS} maxFileSize={MAX_SIZE} />
|
||||
<UploadSectionFile fileType={FILE_TYPE} allowedExtensions={file_extension} maxFileSize={max_file_size} />
|
||||
{/* <TestSection /> */}
|
||||
<FilesTable />
|
||||
</div>
|
||||
|
||||
@@ -1,23 +1,18 @@
|
||||
import ProtectionSummary from '@/app/ui/marking-page/protection-summary';
|
||||
import FilesTable from '@/app/ui/dashboard/files-table';
|
||||
import PageTitle from '@/app/ui/page-title';
|
||||
import UploadSectionFile from '@/app/components/upload-section-file';
|
||||
import FilesTable from '@/app/ui/dashboard/files-table';
|
||||
import { getAllowedFilesExtensions } from '@/app/actions/file-upload';
|
||||
|
||||
const ALLOWED_EXTENSIONS: string[] = ['jpg', 'jpeg', 'png', 'gif', 'bmp'];
|
||||
const FILE_TYPE = "IMAGE"
|
||||
const MAX_SIZE = 1048576000;
|
||||
|
||||
export default async function Page() {
|
||||
/* const allowedFilesExtensions = await getAllowedFilesExtensions(FILE_TYPE);
|
||||
console.log(allowedFilesExtensions);
|
||||
console.log(allowedFilesExtensions); */
|
||||
const FILE_TYPE = "image";
|
||||
const { file_extension, max_file_size } = await getAllowedFilesExtensions(FILE_TYPE);
|
||||
|
||||
return (
|
||||
<div>
|
||||
<PageTitle title="image-protection" />
|
||||
<ProtectionSummary />
|
||||
<UploadSectionFile fileType={FILE_TYPE} allowedExtensions={ALLOWED_EXTENSIONS} maxFileSize={MAX_SIZE} />
|
||||
<UploadSectionFile fileType={FILE_TYPE} allowedExtensions={file_extension} maxFileSize={max_file_size} />
|
||||
{/* <TestSection /> */}
|
||||
<FilesTable />
|
||||
{/* <ProtectedFilesTable /> */}
|
||||
|
||||
@@ -1,20 +1,18 @@
|
||||
import ProtectionSummary from '@/app/ui/marking-page/protection-summary';
|
||||
import UploadSectionVideo from '@/app/ui/marking-page/upload-section-video';
|
||||
import FilesTable from '@/app/ui/dashboard/files-table';
|
||||
import PageTitle from '@/app/ui/page-title';
|
||||
import UploadSectionFile from '@/app/components/upload-section-file';
|
||||
import { getAllowedFilesExtensions } from '@/app/actions/file-upload';
|
||||
|
||||
const ALLOWED_EXTENSIONS: string[] = ['mp4', 'avi', 'webm', 'mkv', 'flv', 'wmv', 'mov'];
|
||||
const FILE_TYPE = "VIDEO"
|
||||
const MAX_SIZE = 1048576000;
|
||||
|
||||
export default function Page() {
|
||||
export default async function Page() {
|
||||
const FILE_TYPE = "video";
|
||||
const { file_extension, max_file_size } = await getAllowedFilesExtensions(FILE_TYPE);
|
||||
|
||||
return (
|
||||
<div>
|
||||
<PageTitle title="video-protection" />
|
||||
<ProtectionSummary />
|
||||
<UploadSectionFile fileType={FILE_TYPE} allowedExtensions={ALLOWED_EXTENSIONS} maxFileSize={MAX_SIZE} />
|
||||
<UploadSectionFile fileType={FILE_TYPE} allowedExtensions={file_extension} maxFileSize={max_file_size} />
|
||||
{/* <TestSection /> */}
|
||||
<FilesTable />
|
||||
</div>
|
||||
|
||||
@@ -187,10 +187,9 @@ export async function getAllowedFilesExtensions(type: string) {
|
||||
|
||||
if (response.ok) {
|
||||
let parsed = await response.json();
|
||||
console.log(parsed);
|
||||
|
||||
if (parsed.message_desc === 'Operation successful') {
|
||||
return parsed.message_body.file_extension;
|
||||
return parsed.message_body;
|
||||
} else {
|
||||
console.log('error cancel getAllowedFilesExtensions');
|
||||
throw parsed;
|
||||
|
||||
@@ -43,7 +43,7 @@ export default function UploadSectionFile({ fileType, allowedExtensions, maxFile
|
||||
let SUPPORTED_FORMATS: string[] = [];
|
||||
|
||||
switch (fileType) {
|
||||
case 'IMAGE':
|
||||
case 'image':
|
||||
SUPPORTED_FORMATS = [
|
||||
'image/jpeg',
|
||||
'image/jpg',
|
||||
@@ -56,7 +56,7 @@ export default function UploadSectionFile({ fileType, allowedExtensions, maxFile
|
||||
'image/x-icon'
|
||||
];
|
||||
break;
|
||||
case 'VIDEO':
|
||||
case 'video':
|
||||
SUPPORTED_FORMATS = [
|
||||
'video/mp4',
|
||||
'video/mpeg',
|
||||
@@ -70,7 +70,7 @@ export default function UploadSectionFile({ fileType, allowedExtensions, maxFile
|
||||
'video/3gpp2'
|
||||
];
|
||||
break;
|
||||
case 'AUDIO':
|
||||
case 'audio':
|
||||
SUPPORTED_FORMATS = [
|
||||
'audio/mpeg',
|
||||
'audio/wav',
|
||||
@@ -159,7 +159,7 @@ export default function UploadSectionFile({ fileType, allowedExtensions, maxFile
|
||||
try {
|
||||
let dimensions = undefined;
|
||||
|
||||
if (fileType === "IMAGE") {
|
||||
if (fileType === "image") {
|
||||
dimensions = await getImageDimensions(file) as { width: number, height: number };
|
||||
if (dimensions.width < 150 || dimensions.height < 150 ||
|
||||
dimensions.width > 10000 || dimensions.height > 10000) {
|
||||
@@ -389,7 +389,7 @@ export default function UploadSectionFile({ fileType, allowedExtensions, maxFile
|
||||
{t('select-files-to-protect')}
|
||||
</button>
|
||||
|
||||
{fileType === "IMAGE" && (
|
||||
{fileType === "image" && (
|
||||
<p className="description">
|
||||
Разрешение изображение: 100x100 - 10000x10000
|
||||
</p>
|
||||
@@ -439,7 +439,7 @@ export default function UploadSectionFile({ fileType, allowedExtensions, maxFile
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{fileType === 'IMAGE' && (
|
||||
{fileType === 'image' && (
|
||||
<img
|
||||
src={selectedFile.preview}
|
||||
alt="Предпросмотр загруженного изображения"
|
||||
|
||||
@@ -6,7 +6,9 @@ import {
|
||||
QueryClientProvider,
|
||||
} from '@tanstack/react-query'
|
||||
|
||||
export function makeQueryClient() {
|
||||
import { getQueryClient } from '@/app/providers/getQueryClient';
|
||||
|
||||
/* export function makeQueryClient() {
|
||||
return new QueryClient({
|
||||
defaultOptions: {
|
||||
queries: {
|
||||
@@ -25,7 +27,7 @@ function getQueryClient() {
|
||||
if (!browserQueryClient) browserQueryClient = makeQueryClient()
|
||||
return browserQueryClient
|
||||
}
|
||||
}
|
||||
} */
|
||||
|
||||
export default function Providers({ children }: { children: React.ReactNode }) {
|
||||
const queryClient = getQueryClient();
|
||||
|
||||
Reference in New Issue
Block a user