FelixGlinka-8988 avatar image
0 Votes"
FelixGlinka-8988 asked SamWu-MSFT commented

Django Chunked Upload IIS 10

I uploaded a program on which a django application is used for file uploading and used the chunk file uploads for it (with the blueimp fileupload on JS side).

When I tested my application locally, it works. When I do it on the IIS production, I always get this error:

POST http://URL/api/chunked_upload/ 500 (Internal Server Error)

The logs in the IIS were not helpful either.

JS Code:
url: window.location.href + 'api/chunked_upload/',
dataType: "json",
maxChunkSize: 100000, // Chunks of 100 kB
formData: form_data,
type: 'POST',
add: function (e, data) {
calculate_md5(data.files[0], 100000);
$("#submitButton").off('click').on("click", function () {
chunkdone: function (e, data) { // Called after uploading each chunk
if (form_data.length < 2) {
{"name": "upload_id", "value": data.result.upload_id}
done: function (e, data) { // Called when the file has completely uploaded
let formInput;
type: "POST",
url: window.location.href + 'api/chunked_upload_complete/',
data: {
csrfmiddlewaretoken: csrf,
upload_id: data.result.upload_id,
md5: md5
dataType: "json",
success: function(data) {
inputForm = document.getElementById('ddGraderForm')
document.getElementById('id_formFile').value = data['file']

Django urls
urlpatterns = [
path('', views.webinterfaceViews, name='main'),
path('api/chunked_upload_complete/', FastaFileUploadCompleteView.as_view(), name='api_chunked_upload_complete'),
path('api/chunked_upload/', FastaFileUploadView.as_view(), name='api_chunked_upload'),

Django view

class FastaFileUploadView(ChunkedUploadView):

 model = fileUpload

 def check_permissions(self, request):
     # Allow non authenticated users to make uploads

class FastaFileUploadCompleteView(ChunkedUploadCompleteView):

 model = fileUpload

 def check_permissions(self, request):
     # Allow non authenticated users to make uploads

 def on_completion(self, uploaded_file, request):
     # Do something with the uploaded file. E.g.:
     # * Store the uploaded file on another model:
     # SomeModel.objects.create(user=request.user, file=uploaded_file)
     # * Pass it as an argument to a function:
     # function_that_process_file(uploaded_file)

 def get_response_data(self, chunked_upload, request):
     return {'file':, 'filename': chunked_upload.filename}


The error code I receive is
BytesReceived="0", ErrorCode="Reached the end of the file.

Headers="Content-Type: text/html
Vary: Cookie
Server: Microsoft-IIS/10.0
X-Frame-Options: DENY
X-Content-Type-Options: nosniff
Referrer-Policy: same-origin
X-Powered-By: ASP.NET

· 5
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@FelixGlinka-8988 After using failed request tracking, you should analyze the xml file in the log, and the error message should be as shown in this link, not the content you posted.

0 Votes 0 ·

Yeah, sure. Here the two screenshots of the xml, I hope its enough.
For some reason, I cannot upload the whole thing...


0 Votes 0 ·
pageonexml.png (29.3 KiB)
pagethreexml.png (128.6 KiB)

@FelixGlinka-8988 Since you can't get the error message from frt, you need to check Django logging, but before that, you can refer to this link on how to configure python web apps for IIS, and check if there are any problems during the deployment process. besides, the most common cause of 500 error is a misconfiguration of either the FastCGI application or the root web.config file. You need to be sure that the The scriptProcessor attribute of the web.config matches Full Path and the Arguments of the FastCGI application.

0 Votes 0 ·

I could manage to include the pythonhandler with the right scriptProcessor.
The only tag I have issues with is the httpplatform, which does not work properly? Is this crucial I did like in the link or like host-flask-and-django-web-application-with-windows-iis-httpplatformhanlder-83e831ce91bc, but it did not work.
Otherwise my program works, just the interface with the /api/chunked_upload/ last bit does not.

0 Votes 0 ·
Show more comments

0 Answers