Technically the WSGI specification doesn't allow chunked request content. There is however an unofficial extension that is supported by some WSGI servers to indicate that request content with an unspecified/mutable length is being supplied. This can be used to enable chunked request content to be handled, albeit that you may need to also configure the WSGI server to allow chunked requests as well.
but with ajax you can uplaod directly to your swift.
$("#fileUpload").change(function () {
var myFile = $(this)[0].files[0];
ajax = new XMLHttpRequest();
ajax.onreadystatechange = function () {
if (ajax.status) {
if (ajax.status == 200 && ajax.readyState == 4) {
//To do tasks if any, when upload is completed
}
}
};
ajax.upload.addEventListener("progress", function (event) {
var percent = (event.loaded / event.total) * 100;
//**percent** variable can be used for modifying the length of your progress bar.
console.log(+percent.toFixed(2) + "%");
});
ajax.open(
"PUT",
"http://swift:8080/v1/AUTH_ACCOUNT/CONTAINER/" + myFile.name,
true
);
ajax.setRequestHeader("Content-type", myFile.type);
ajax.setRequestHeader(
"X-Auth-Token",
"TOKEN"
);
ajax.send(myFile);
//ajax.send is for uploading form data.
});
int the HTML file we have :
<label class="btn btn-cyan" for="fileUpload">
<span aria-hidden="true">upload</span>
<input id="fileUpload" type="file" style="display:none">
</label>
for this solution you have to access the swift-proxy (http://swift:8080), you can request to your host(e.x your horizon host) the proxy pass to your local swift.
you can configure your host apache for redirecting in this way:
Listen 8080
<VirtualHost *:8080>
ProxyPreserveHost On
ProxyPass / http://swift:8080/
ProxyPassReverse / http://swift:8080/
# ServerName localhost
</VirtualHost>