pinafore/routes/_api/media.js
Nolan Lawson 7ae3212c55
Fix alts for image uploads (#54)
* Fix alts for image uploads

Fixes #41

* fix alts mixed with no-alts
2018-04-09 18:30:15 -07:00

18 lines
665 B
JavaScript

import { auth, basename } from './utils'
import { postWithTimeout, putWithTimeout } from '../_utils/ajax'
export async function uploadMedia (instanceName, accessToken, file, description) {
let formData = new FormData()
formData.append('file', file)
if (description) {
formData.append('description', description)
}
let url = `${basename(instanceName)}/api/v1/media`
return postWithTimeout(url, formData, auth(accessToken))
}
export async function putMediaDescription (instanceName, accessToken, mediaId, description) {
let url = `${basename(instanceName)}/api/v1/media/${mediaId}`
return putWithTimeout(url, {description}, auth(accessToken))
}