From a2072165aacff75e06aad0fa435f7d2de92dc6bc Mon Sep 17 00:00:00 2001 From: Angelina Filippova Date: Wed, 1 Apr 2020 18:51:17 +0300 Subject: [PATCH] Implement multipart request for uploading emojis --- src/api/emojiPacks.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/api/emojiPacks.js b/src/api/emojiPacks.js index df61dd58..61319cec 100644 --- a/src/api/emojiPacks.js +++ b/src/api/emojiPacks.js @@ -3,15 +3,21 @@ import { getToken } from '@/utils/auth' import { baseName } from './utils' export async function addNewEmojiFile(packName, file, shortcode, filename, host, token) { + const data = new FormData() + if (filename.trim() !== '') { + data.set('filename', filename) + } + if (shortcode.trim() !== '') { + data.set('shortcode', shortcode) + } + data.set('file', file) + return await request({ baseURL: baseName(host), url: `/api/pleroma/emoji/packs/${packName}/files`, method: 'post', headers: authHeaders(token), - data: { - file, - shortcode: shortcode.trim() !== '' ? shortcode : null, - filename: filename.trim() !== '' ? filename : null } + data }) }