The photos come in a byte array. Sending an object list include byte array to controller with ajax.
As the quality of the photos increases, the byte array grows, which makes it a mistake. Not going to controller. However, when the quality of the photos is low, the operation is successful.
I think json gives error because size is big.
$.ajax({
type: "GET",
url: photoApi,
crossDomain: true,
dataType: "json",
success: function (data) {
$.each(data,
function (i, list) {
$.each(list,
function (i, ves) {
var Picture = new Uint8Array(ves.Picture)
// adding to list
photoObj["items"].push({ "Id": ves.Id, "Picture": btoa(String.fromCharCode.apply(null, Picture)), "User": ves.User, "CreatedDate": ves.CreatedDate });
}
);
$.ajax({
type: 'POST',
url: '/File/Photo',
data: JSON.stringify(photoObj),
contentType: "application/json; charset=utf-8",
success: function (data) {
$("#divAttachments").html(data);
},
error: function (ex) {
//comes here when photo quality improves
alert('error' + ex);
}
});
});
},
error: function (request, status, error) {
console.log(request);
}
});