diff options
Diffstat (limited to 'animism-align/frontend/app/api/crud.upload.js')
| -rw-r--r-- | animism-align/frontend/app/api/crud.upload.js | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/animism-align/frontend/app/api/crud.upload.js b/animism-align/frontend/app/api/crud.upload.js index b4d9d4e..2837dd4 100644 --- a/animism-align/frontend/app/api/crud.upload.js +++ b/animism-align/frontend/app/api/crud.upload.js @@ -1,4 +1,5 @@ import { as_type } from 'app/api/crud.types' +import { session } from 'app/session' export function crud_upload(type, data, dispatch) { return new Promise( (resolve, reject) => { @@ -13,7 +14,7 @@ export function crud_upload(type, data, dispatch) { Object.keys(data).forEach(key => { if (key.indexOf('__') !== -1) return if (key === 'id') return - const fn_key = '__' + key + '_filename' + const fn_key = `__${key}_filename` if (fn_key in data) { fd.append(key, data[key], data[fn_key]) } else { @@ -31,12 +32,11 @@ export function crud_upload(type, data, dispatch) { xhr.addEventListener("error", uploadFailed, false) xhr.addEventListener("abort", uploadCancelled, false) xhr.open("POST", url) + xhr.setRequestHeader("Authorization", "Bearer " + session.get("access_token")) xhr.send(fd) dispatch && dispatch({ type: as_type(type, 'upload_loading')}) - let complete = false - function uploadProgress (e) { if (e.lengthComputable) { const percent = Math.round(e.loaded * 100 / e.total) || 0 |
