1
0
mirror of https://gitlab.com/comunic/comunicapiv2 synced 2025-06-20 16:45:16 +00:00

Add PDF support

This commit is contained in:
2020-03-20 12:10:48 +01:00
parent 0a1626dc47
commit 5c8c3be9ae
2 changed files with 47 additions and 2 deletions

View File

@ -204,7 +204,7 @@ export class PostsController {
// Personnal movies
// Personnal movies posts
case PostKind.POST_KIND_MOVIE:
const movieID = h.postInt("movieID");
@ -216,7 +216,7 @@ export class PostsController {
break;
// Web links
// Web links posts
case PostKind.POST_KIND_WEBLINK:
const url = h.postURL("url");
@ -231,6 +231,24 @@ export class PostsController {
break;
// PDF posts
case PostKind.POST_KIND_PDF:
if(!h.hasFile("pdf"))
h.error(401, "Missing PDF in 'pdf'!");
const pdf_path = await h.savePostFile("pdf", "post_pdf", "pdf", "application/pdf");
newPost.file = new PostFile({
path: pdf_path,
type: <string>lookup(pathUserData(pdf_path, true)),
size: statSync(pathUserData(pdf_path, true)).size
});
break;
default:
h.error(500, "Unsupported kind of post!");