fedilove-ui/routes/_api/media.js

18 lines
665 B
JavaScript
Raw Normal View History

2018-03-02 05:21:49 +00:00
import { auth, basename } from './utils'
import { postWithTimeout, putWithTimeout } from '../_utils/ajax'
2018-03-02 05:21:49 +00:00
2018-03-06 06:36:54 +00:00
export async function uploadMedia (instanceName, accessToken, file, description) {
2018-03-02 05:21:49 +00:00
let formData = new FormData()
formData.append('file', file)
if (description) {
formData.append('description', description)
}
2018-03-02 05:21:49 +00:00
let url = `${basename(instanceName)}/api/v1/media`
return postWithTimeout(url, formData, auth(accessToken))
2018-03-03 01:54:38 +00:00
}
export async function putMediaDescription (instanceName, accessToken, mediaId, description) {
let url = `${basename(instanceName)}/api/v1/media/${mediaId}`
return putWithTimeout(url, {description}, auth(accessToken))
}