mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-19 17:55:17 -04:00
added upload functionality (#758)
Co-authored-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de> Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de> Signed-off-by: Philip Molares <philip.molares@udo.edu>
This commit is contained in:
parent
8ce344512c
commit
0c0841639a
20 changed files with 401 additions and 73 deletions
|
@ -18,3 +18,21 @@ export const getProxiedUrl = async (imageUrl: string): Promise<ImageProxyRespons
|
|||
expectResponseCode(response)
|
||||
return await response.json() as Promise<ImageProxyResponse>
|
||||
}
|
||||
|
||||
export interface UploadedMedia {
|
||||
link: string
|
||||
}
|
||||
|
||||
export const uploadFile = async (noteId: string, contentType: string, media: Blob): Promise<UploadedMedia> => {
|
||||
const response = await fetch(getApiUrl() + '/media/upload', {
|
||||
...defaultFetchConfig,
|
||||
headers: {
|
||||
'Content-Type': contentType,
|
||||
'HedgeDoc-Note': noteId
|
||||
},
|
||||
method: 'POST',
|
||||
body: media
|
||||
})
|
||||
expectResponseCode(response, 201)
|
||||
return await response.json() as Promise<UploadedMedia>
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue