From 7074fb86c30c934376c8e5173873b973569f03e4 Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Sat, 3 Mar 2018 00:20:10 +0100 Subject: [PATCH] Generic uploadFile --- scripts/Actions/Upload.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/Actions/Upload.ts b/scripts/Actions/Upload.ts index 72e91cc6..bf5efffd 100644 --- a/scripts/Actions/Upload.ts +++ b/scripts/Actions/Upload.ts @@ -10,7 +10,7 @@ export function selectFile(arn: AnimeNotifier, button: HTMLButtonElement) { let file = input.files[0] previewImage(file, preview) - uploadImage(file) + uploadFile(file, "/api/upload/avatar") } input.click() @@ -32,12 +32,12 @@ function previewImage(file: File, preview: HTMLImageElement) { } } -// Upload image -function uploadImage(file: File) { +// Upload file +function uploadFile(file: File, endpoint: string) { let reader = new FileReader() reader.onloadend = async () => { - await fetch("/api/upload/avatar", { + await fetch(endpoint, { method: "POST", credentials: "include", headers: {