var ajaxResponse = $.ajaxQueue({
type: "POST",
url: "/Upload/Upload",
enctype: 'multipart/form-data',
contentType: false,
processData: false,
async: true,
beforeSend: function(request) {
request.setRequestHeader("serviceUrl", getToLocalStorage("serviceUrl"));
request.setRequestHeader("token", getToLocalStorage("token"));
connection.on("lastprogress", function (itemId, progresbar) {
$(".progress-bar").each(function (index, element) {
var fileid = $(this).data("fileid");
if (fileid === itemId) {
$(this).width(progresbar + "%");
}
var obj = CancelUploadFileList.find(el => el == object.itemId);
if (obj) {
$(".progress-bar").each(function (index, element) {
var fileid = $(this).data("fileid");
if (fileid === object.itemId) {
$(this).removeClass("progress-bar");
$(this).parent().removeClass("progress-custom");
$(this).html("<div style='font-weight:normal;'>Canceled</div>");
ajaxResponse.abort();
// $(this).innerHTML("Canceled");
}
});
}
});
// var progressBarValue = $(".progress-custom").find("[data-fileid='" + uploadFileCollectionList[i].itemId + "']").val();
// $('.progress-bar').eq(count - 1).width(progresbar + "%");
//if (progresbar == 100) {
// connection.on("uploadcontrol", function (isboolean, itemId) {
// if (isboolean) {
// $('.remove-from-list').each(function (index, element) {
// if ($(this).data("fileid") === itemId) {
// $(this).removeClass("red").removeClass("stop").addClass("green").addClass("check");
// }
// });
// }
// });
//}
}
);
try {
connection.start().catch(err => console.log(err.toString())).then(response => console.log("connected"));//unutma
} catch (e) {
}
},
headers: { 'serviceUrl': getToLocalStorage("serviceUrl"), 'token': getToLocalStorage("token") },
data: formData,
success: function (data) {
if (data.success) {
UploadControl(newItemId, object.overWrite);
}
else {
$(function () {
new PNotify({
//
text: data.message == null ? object.itemName+" file is empty": data.message,
type: "error",
addClass: ".notifybg",
delay: 5000
});
});
}
},
error: function (data) {
var uploadedFile = uploadFileCollectionListData.findIndex(el => el.itemId == newItemId);
uploadFileCollectionListData.splice(uploadedFile, 1);
}
});
while (bytesToRead > 0)
{
int n = stream.Read(buffer, 0, chunkSize);
if (n == 0) break;
if (n != buffer.Length)
Array.Resize(ref buffer, n);
var newToken= _progressHub.Clients.Client().In
uploadCloudItem = UploadCloudItem(token, new MemoryStream(buffer), u);
bytesRead += n;
bytesToRead -= n;
var progress = (int)((float)bytesRead / (float)uploadRequest.itemSize * 100.0);
_progressHub.Clients.All.SendAsync("lastprogress", u.itemId, progress);
Task.Delay(500);
}
How do I send token information to the server side with signalR? How do I send token information to the server side with signalR? I'm uploading files with jquery, but the token expires when the file size is large. how do i send my current token How do I send token information to the server side with signalR?