Fix media upload

This commit is contained in:
Dennis Eichhorn 2018-11-03 15:21:25 +01:00
parent 727fee799a
commit 577af40f56
4 changed files with 17 additions and 13 deletions

View File

@ -56,6 +56,8 @@
return 'application/json';
case jsOMS.Message.Request.RequestType.URL_ENCODE:
return 'application/x-www-form-urlencoded';
case jsOMS.Message.Request.RequestType.FILE:
return '';
default:
return 'text/plain';
}
@ -308,7 +310,8 @@
*/
setType(type)
{
this.type = type;
this.type = type;
this.requestHeader['Content-Type'] = this.setContentTypeBasedOnType(this.type);
};
/**
@ -365,12 +368,14 @@
this.xhr.open(this.method, jsOMS.Uri.UriFactory.build(this.uri));
for (let p in this.requestHeader) {
if (this.requestHeader.hasOwnProperty(p)) {
if (this.requestHeader.hasOwnProperty(p) && this.requestHeader[p] !== '') {
this.xhr.setRequestHeader(p, this.requestHeader[p]);
}
}
}
console.log(this.xhr);
this.xhr.onreadystatechange = function()
{
switch (self.xhr.readyState) {
@ -381,12 +386,6 @@
self.result[self.xhr.status](self.xhr);
}
break;
case 2:
// todo: handle server received request
break;
case 3:
// todo: server is handling request
break;
default:
// todo: create handler for error returns
}
@ -394,7 +393,9 @@
if (this.type === jsOMS.Message.Request.RequestType.JSON) {
this.xhr.send(JSON.stringify(this.data));
} else if (this.type === jsOMS.Message.Request.RequestType.RAW) {
} else if (this.type === jsOMS.Message.Request.RequestType.RAW
|| this.type === jsOMS.Message.Request.RequestType.FILE
) {
this.xhr.send(this.data);
} else if (this.type === jsOMS.Message.Request.RequestType.URL_ENCODE) {
this.xhr.send(this.queryfy(this.data));

View File

@ -16,6 +16,7 @@
jsOMS.Message.Request.RequestType = Object.freeze({
JSON: 'json',
RAW: 'raw',
FILE: 'file',
URL_ENCODE: 'url'
});
}(window.jsOMS = window.jsOMS || {}));

View File

@ -177,7 +177,9 @@
}
}
this.app.eventManager.trigger(form.getId());
if (counter < 1) {
this.app.eventManager.trigger(form.getId());
}
};
/**

View File

@ -93,9 +93,9 @@
getSubmit ()
{
return document.querySelectorAll(
'#' + this.id + ' input[type=submit],'
+ ' button[form=' + this.id + '][type=submit],'
+ ' #' + this.id + ' button[type=submit]'
'#' + this.id + ' input[type=submit], '
+ 'button[form=' + this.id + '][type=submit], '
+ '#' + this.id + ' button[type=submit]'
);
};