forked from srxl/akkoma-fe
Add media upload to API Service.
This commit is contained in:
parent
86749f759d
commit
f86f0ef7f0
1 changed files with 13 additions and 2 deletions
|
@ -6,8 +6,8 @@ const PUBLIC_AND_EXTERNAL_TIMELINE_URL = '/api/statuses/public_and_external_time
|
|||
const FAVORITE_URL = '/api/favorites/create'
|
||||
const UNFAVORITE_URL = '/api/favorites/destroy'
|
||||
const STATUS_UPDATE_URL = '/api/statuses/update.json'
|
||||
const MEDIA_UPLOAD_URL = '/api/statusnet/media/upload'
|
||||
// const CONVERSATION_URL = '/api/statusnet/conversation/';
|
||||
// const MEDIA_UPLOAD_URL = '/api/statusnet/media/upload';
|
||||
|
||||
// const FORM_CONTENT_TYPE = {'Content-Type': 'application/x-www-form-urlencoded'};
|
||||
|
||||
|
@ -75,12 +75,23 @@ const postStatus = ({credentials, status, mediaIds, inReplyToStatusId}) => {
|
|||
})
|
||||
}
|
||||
|
||||
const uploadMedia = ({formData, credentials}) => {
|
||||
return fetch(MEDIA_UPLOAD_URL, {
|
||||
body: formData,
|
||||
method: 'POST',
|
||||
headers: authHeaders(credentials)
|
||||
})
|
||||
.then((response) => response.text())
|
||||
.then((text) => (new DOMParser()).parseFromString(text, 'application/xml'))
|
||||
}
|
||||
|
||||
const apiService = {
|
||||
verifyCredentials,
|
||||
fetchTimeline,
|
||||
favorite,
|
||||
unfavorite,
|
||||
postStatus
|
||||
postStatus,
|
||||
uploadMedia
|
||||
}
|
||||
|
||||
export default apiService
|
||||
|
|
Loading…
Reference in a new issue