From 53937e09a0bef968dfd6d5b0f2580de876685aa0 Mon Sep 17 00:00:00 2001 From: syuilo Date: Thu, 20 Jan 2022 02:40:13 +0900 Subject: [PATCH] feat(server): store mime type of webpublic --- .../1642613870898-drive-file-webpublic-type.js | 13 +++++++++++++ packages/backend/src/models/entities/drive-file.ts | 5 +++++ packages/backend/src/services/drive/add-file.ts | 2 ++ 3 files changed, 20 insertions(+) create mode 100644 packages/backend/migration/1642613870898-drive-file-webpublic-type.js diff --git a/packages/backend/migration/1642613870898-drive-file-webpublic-type.js b/packages/backend/migration/1642613870898-drive-file-webpublic-type.js new file mode 100644 index 000000000..e10c2ac2d --- /dev/null +++ b/packages/backend/migration/1642613870898-drive-file-webpublic-type.js @@ -0,0 +1,13 @@ +const { MigrationInterface, QueryRunner } = require("typeorm"); + +module.exports = class driveFileWebpublicType1642613870898 { + name = 'driveFileWebpublicType1642613870898' + + async up(queryRunner) { + await queryRunner.query(`ALTER TABLE "drive_file" ADD "webpublicType" character varying(128)`); + } + + async down(queryRunner) { + await queryRunner.query(`ALTER TABLE "drive_file" DROP COLUMN "webpublicType"`); + } +} diff --git a/packages/backend/src/models/entities/drive-file.ts b/packages/backend/src/models/entities/drive-file.ts index 0af52d7cc..cec86880f 100644 --- a/packages/backend/src/models/entities/drive-file.ts +++ b/packages/backend/src/models/entities/drive-file.ts @@ -101,6 +101,11 @@ export class DriveFile { }) public webpublicUrl: string | null; + @Column('varchar', { + length: 128, nullable: true, + }) + public webpublicType: string | null; + @Index({ unique: true }) @Column('varchar', { length: 256, nullable: true, diff --git a/packages/backend/src/services/drive/add-file.ts b/packages/backend/src/services/drive/add-file.ts index 1153cf737..6ac4f6d11 100644 --- a/packages/backend/src/services/drive/add-file.ts +++ b/packages/backend/src/services/drive/add-file.ts @@ -101,6 +101,7 @@ async function save(file: DriveFile, path: string, name: string, type: string, h file.accessKey = key; file.thumbnailAccessKey = thumbnailKey; file.webpublicAccessKey = webpublicKey; + file.webpublicType = alts.webpublic?.type ?? null; file.name = name; file.type = type; file.md5 = hash; @@ -135,6 +136,7 @@ async function save(file: DriveFile, path: string, name: string, type: string, h file.accessKey = accessKey; file.thumbnailAccessKey = thumbnailAccessKey; file.webpublicAccessKey = webpublicAccessKey; + file.webpublicType = alts.webpublic?.type ?? null; file.name = name; file.type = type; file.md5 = hash;