diff --git a/prisma/migrations/20230115214317_file_original_name/migration.sql b/prisma/migrations/20230115214317_file_original_name/migration.sql new file mode 100644 index 0000000..442095a --- /dev/null +++ b/prisma/migrations/20230115214317_file_original_name/migration.sql @@ -0,0 +1,8 @@ +-- AlterTable +ALTER TABLE "File" ADD COLUMN "originalName" TEXT; + +-- RenameForeignKey +ALTER TABLE "File" RENAME CONSTRAINT "Image_userId_fkey" TO "File_userId_fkey"; + +-- RenameIndex +ALTER INDEX "InvisibleImage_invis_key" RENAME TO "InvisibleFile_invis_key"; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 8df53dc..62823eb 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -36,6 +36,7 @@ enum FileNameFormat { model File { id Int @id @default(autoincrement()) name String + originalName String? mimetype String @default("image/png") createdAt DateTime @default(now()) expiresAt DateTime? diff --git a/src/components/pages/Upload/File.tsx b/src/components/pages/Upload/File.tsx index 61c8fe2..8fe7f1e 100644 --- a/src/components/pages/Upload/File.tsx +++ b/src/components/pages/Upload/File.tsx @@ -163,6 +163,7 @@ export default function File({ chunks: chunks_config }) { options.embedded && req.setRequestHeader('Embed', 'true'); options.zeroWidth && req.setRequestHeader('Zws', 'true'); options.format !== 'default' && req.setRequestHeader('Format', options.format); + options.originalName && req.setRequestHeader('Original-Name', 'true'); req.send(body); @@ -274,6 +275,7 @@ export default function File({ chunks: chunks_config }) { options.embedded && req.setRequestHeader('Embed', 'true'); options.zeroWidth && req.setRequestHeader('Zws', 'true'); options.format !== 'default' && req.setRequestHeader('Format', options.format); + options.originalName && req.setRequestHeader('Original-Name', 'true'); req.send(body); } diff --git a/src/components/pages/Upload/Text.tsx b/src/components/pages/Upload/Text.tsx index 9dfd871..bd661a4 100644 --- a/src/components/pages/Upload/Text.tsx +++ b/src/components/pages/Upload/Text.tsx @@ -70,6 +70,7 @@ export default function Text() { options.embedded && req.setRequestHeader('Embed', 'true'); options.zeroWidth && req.setRequestHeader('Zws', 'true'); options.format !== 'default' && req.setRequestHeader('Format', options.format); + options.originalName && req.setRequestHeader('Original-Name', 'true'); req.send(body); }; diff --git a/src/components/pages/Upload/useUploadOptions.tsx b/src/components/pages/Upload/useUploadOptions.tsx index a0e88ff..1568d65 100644 --- a/src/components/pages/Upload/useUploadOptions.tsx +++ b/src/components/pages/Upload/useUploadOptions.tsx @@ -22,6 +22,7 @@ export default function useUploadOptions(): [ zeroWidth: boolean; embedded: boolean; format: string; + originalName: boolean; }, Dispatch>, React.FC @@ -34,6 +35,7 @@ export default function useUploadOptions(): [ zeroWidth: false, embedded: false, format: 'default', + originalName: false, }); const [opened, setOpened] = useState(false); @@ -47,6 +49,7 @@ export default function useUploadOptions(): [ zeroWidth: false, embedded: false, format: 'default', + originalName: false, }); }; @@ -146,6 +149,13 @@ export default function useUploadOptions(): [ checked={state.embedded} onChange={(e) => setState({ embedded: e.currentTarget.checked })} /> + + setState({ originalName: e.currentTarget.checked })} + />