mirror of
https://github.com/nolanlawson/pinafore
synced 2024-12-12 18:28:03 +01:00
8dbc1b0503
* chore(package): update standard to version 12.0.0 * package lock update * fix eslint
18 lines
721 B
JavaScript
18 lines
721 B
JavaScript
import { auth, basename } from './utils'
|
|
import { post, put, MEDIA_WRITE_TIMEOUT, WRITE_TIMEOUT } 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 post(url, formData, auth(accessToken), { timeout: MEDIA_WRITE_TIMEOUT })
|
|
}
|
|
|
|
export async function putMediaDescription (instanceName, accessToken, mediaId, description) {
|
|
let url = `${basename(instanceName)}/api/v1/media/${mediaId}`
|
|
return put(url, { description }, auth(accessToken), { timeout: WRITE_TIMEOUT })
|
|
}
|