diff options
| author | Roger Braun <roger@rogerbraun.net> | 2016-11-06 19:29:41 +0100 |
|---|---|---|
| committer | Roger Braun <roger@rogerbraun.net> | 2016-11-06 19:29:41 +0100 |
| commit | f86f0ef7f02ff68cfa2cd80ac38b0073314399b6 (patch) | |
| tree | 3a4e95af2078eef0a4a994e8a6b49c8587fed01c /src | |
| parent | 86749f759d6b2f75871242ba1edcd53e6d8ab14c (diff) | |
Add media upload to API Service.
Diffstat (limited to 'src')
| -rw-r--r-- | src/services/api/api.service.js | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/services/api/api.service.js b/src/services/api/api.service.js index df7b4190..c9fcc4f6 100644 --- a/src/services/api/api.service.js +++ b/src/services/api/api.service.js @@ -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 |
