mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-28 16:00:59 -05:00
Do not save file extension as a separate field.
It turned out that saving the file extension in a separate field is not necessary. Instead, the extension is saved in the complete filename in the `id` field. Signed-off-by: David Mehren <git@herrmehren.de>
This commit is contained in:
parent
dc49bfcccb
commit
23ba2026cc
2 changed files with 6 additions and 10 deletions
|
@ -120,7 +120,6 @@ entity "MediaUpload" {
|
||||||
--
|
--
|
||||||
*noteId : uuid <<FK Note>>
|
*noteId : uuid <<FK Note>>
|
||||||
*userId : uuid <<FK User>>
|
*userId : uuid <<FK User>>
|
||||||
*extension : text
|
|
||||||
*backendType: text
|
*backendType: text
|
||||||
backendData: text
|
backendData: text
|
||||||
*createdAt : date
|
*createdAt : date
|
||||||
|
|
|
@ -8,6 +8,9 @@ import {
|
||||||
} from 'typeorm';
|
} from 'typeorm';
|
||||||
import { Note } from '../notes/note.entity';
|
import { Note } from '../notes/note.entity';
|
||||||
import { User } from '../users/user.entity';
|
import { User } from '../users/user.entity';
|
||||||
|
import { BackendType } from './backends/backend-type.enum';
|
||||||
|
|
||||||
|
export type BackendData = string | null;
|
||||||
|
|
||||||
@Entity()
|
@Entity()
|
||||||
export class MediaUpload {
|
export class MediaUpload {
|
||||||
|
@ -20,11 +23,6 @@ export class MediaUpload {
|
||||||
@ManyToOne(_ => User, { nullable: false })
|
@ManyToOne(_ => User, { nullable: false })
|
||||||
user: User;
|
user: User;
|
||||||
|
|
||||||
@Column({
|
|
||||||
nullable: false,
|
|
||||||
})
|
|
||||||
extension: string;
|
|
||||||
|
|
||||||
@Column({
|
@Column({
|
||||||
nullable: false,
|
nullable: false,
|
||||||
})
|
})
|
||||||
|
@ -33,7 +31,7 @@ export class MediaUpload {
|
||||||
@Column({
|
@Column({
|
||||||
nullable: true,
|
nullable: true,
|
||||||
})
|
})
|
||||||
backendData: string | null;
|
backendData: BackendData;
|
||||||
|
|
||||||
@CreateDateColumn()
|
@CreateDateColumn()
|
||||||
createdAt: Date;
|
createdAt: Date;
|
||||||
|
@ -45,15 +43,14 @@ export class MediaUpload {
|
||||||
note: Note,
|
note: Note,
|
||||||
user: User,
|
user: User,
|
||||||
extension: string,
|
extension: string,
|
||||||
backendType: string,
|
backendType: BackendType,
|
||||||
backendData?: string,
|
backendData?: string,
|
||||||
): MediaUpload {
|
): MediaUpload {
|
||||||
const upload = new MediaUpload();
|
const upload = new MediaUpload();
|
||||||
const randomBytes = crypto.randomBytes(16);
|
const randomBytes = crypto.randomBytes(16);
|
||||||
upload.id = randomBytes.toString('hex');
|
upload.id = randomBytes.toString('hex') + '.' + extension;
|
||||||
upload.note = note;
|
upload.note = note;
|
||||||
upload.user = user;
|
upload.user = user;
|
||||||
upload.extension = extension;
|
|
||||||
upload.backendType = backendType;
|
upload.backendType = backendType;
|
||||||
if (backendData) {
|
if (backendData) {
|
||||||
upload.backendData = backendData;
|
upload.backendData = backendData;
|
||||||
|
|
Loading…
Reference in a new issue