mirror of
https://github.com/rzmk/learnhouse.git
synced 2025-12-19 04:19:25 +00:00
feat: add pdf extension to editor
This commit is contained in:
parent
429a95c50a
commit
fdcee29a0d
7 changed files with 297 additions and 6 deletions
20
front/services/files/documents.ts
Normal file
20
front/services/files/documents.ts
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
import { getAPIUrl } from "@services/config";
|
||||
import { RequestBody, RequestBodyForm } from "@services/utils/requests";
|
||||
|
||||
export async function uploadNewPDFFile(file: any, lecture_id: string) {
|
||||
// Send file thumbnail as form data
|
||||
const formData = new FormData();
|
||||
formData.append("file_object", file);
|
||||
formData.append("lecture_id", lecture_id);
|
||||
|
||||
return fetch(`${getAPIUrl()}files/document`, RequestBodyForm("POST", formData))
|
||||
.then((result) => result.json())
|
||||
.catch((error) => console.log("error", error));
|
||||
}
|
||||
|
||||
export async function getPDFFile(file_id: string) {
|
||||
// todo : add course id to url
|
||||
return fetch(`${getAPIUrl()}files/document?file_id=${file_id}`, RequestBody("GET", null))
|
||||
.then((result) => result.json())
|
||||
.catch((error) => console.log("error", error));
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue