Implement multipart request for uploading emojis
This commit is contained in:
parent
32432e1f6e
commit
a2072165aa
1 changed files with 10 additions and 4 deletions
|
@ -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
|
||||
})
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue