From a48204ea407cd141f5db47e45145a14e7147014c Mon Sep 17 00:00:00 2001 From: Jannis Mattheis Date: Fri, 30 Mar 2018 19:33:59 +0200 Subject: [PATCH] Add upload image action --- ui/src/actions/AppAction.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/ui/src/actions/AppAction.js b/ui/src/actions/AppAction.js index c70a5a2..69df5a8 100644 --- a/ui/src/actions/AppAction.js +++ b/ui/src/actions/AppAction.js @@ -18,10 +18,22 @@ export function deleteApp(id) { } /** - * Create an application + * Create an application. * @param {string} name the application name * @param {string} description the description of the application. */ export function createApp(name, description) { axios.post(config.get('url') + 'application', {name, description}).then(fetchApps); } + +/** + * Upload an image for an application. + * @param {int} id the application id + * @param {Blob} file the description of the application. + */ +export function uploadImage(id, file) { + const formData = new FormData(); + formData.append('file', file); + axios.post(config.get('url') + 'application/' + id + '/image', formData, + {headers: {'content-type': 'multipart/form-data'}}).then(fetchApps); +}