Это моя серверная функция. Я пытаюсь вернуть код InternalServerError в dropzone. Тем не менее, это всегда говорит, что это успешно.
Я зарегистрировал все свои возвращенные куски, и его код состояния также является успешным.
Я что-то пропустил на заднем или переднем конце?
[ValidateAntiForgeryToken]
[HttpPost]
public async Task<HttpResponseMessage> SaveC(UploadDocumentViewModel Input)
{
HttpResponseMessage response = new HttpResponseMessage { StatusCode = HttpStatusCode.Created };
var Req = Request.Form;
var b = Request.Form["RepositoryId"].ToString().Replace("{", "").Replace("}", "");
if (Request.Form["RepositoryId"].ToString().Replace("{", "").Replace("}", "") == "")
{
response.StatusCode = HttpStatusCode.InternalServerError;
response.Content = new StringContent("Chunk upload task is faulted or canceled!");
}
return response;
}
Это мой javascript:
Dropzone.options.dropzone = {
url:"@Url.Action("SaveC", "Document", new { area="Document"})",
autoProcessQueue: false,
addRemoveLinks: false,
uploadMultiple: false,
parallelUploads: 1,
chunking: true,
forceChunking: true,
chunkSize: 100000,
parallelChunkUploads: true,
retryChunks: true,
retryChunksLimit: 3,
params: function (files, xhr, chunk) {
if (chunk) {
console.log(chunk);
return {
dzUuid: chunk.file.upload.uuid,
dzChunkIndex: chunk.index,
dzTotalFileSize: chunk.file.size,
dzCurrentChunkSize: chunk.dataBlock.data.size,
dzTotalChunkCount: chunk.file.upload.totalChunkCount,
dzChunkByteOffset: chunk.index * this.options.chunkSize,
dzChunkSize: this.options.chunkSize,
dzFilename: chunk.file.name,
};
}
},
chunksUploaded: function (file, done) {
//console.log(file);
//console.log(done);
$("#UploadActivity").val($("#UploadActivity").val() + file.name+ " " + file.status + "\r\n");
this.autoProcessQueue = true;
done();
},
init: function () {
var submitButton = document.querySelector("#submit");
var resetButton = document.querySelector("#reset");
var token = $('input[name="__RequestVerificationToken"]').val();
var wrapperThis = this;
submitButton.addEventListener("click", function (e) {
wrapperThis.processQueue();
e.preventDefault();
e.stopPropagation();
e.stopImmediatePropagation();
return false;
});
this.on('sending', function (data, xhr, formData) {
formData.append("__RequestVerificationToken",token);
formData.append("@Html.IdFor(x => x.CategoryId)", $("#@Html.IdFor(x => x.CategoryId)").val());
formData.append("@Html.IdFor(x => x.RepositoryId)", $("#@Html.IdFor(x => x.RepositoryId)").val());
formData.append("@Html.IdFor(x => x.BatchId)", $("#@Html.IdFor(x => x.BatchId)").val());
formData.append("@Html.IdFor(x => x.BatchName)", $("#@Html.IdFor(x => x.BatchName)").val());
});;
this.on('error', function (file, message) {
//toastr.error(message);
console.log("Error");
$("#UploadActivity").val($("#UploadActivity").val() + file.name + " " + file.status + "\r\n");
wrapperThis.disable();
});
this.on('success', function (file, message) {
console.log(file);
console.log(message);
$("#UploadActivity").val($("#UploadActivity").val() + file.name + " " + file.status + "\r\n");
$(".dz-remove").hide();
@*window.location.replace("@Url.Action("View","Batch",new { area="Batch"})?BatchId=@Model.BatchId");*@
});
this.on("queuecomplete", function () {
//save to a counter
//if all successful, move to next page
console.log("ALL COMPLETED");
this.options.autoProcessQueue = false;
})
}
};