Have a repetitive process on the client side of a Web Report that slices and dices a number of "csv" files to create a JSON data source for a grid which is consumed by another WR to display the data in a formatted grid. The process is working using html input type="file" for the three (3) input selectors and the one (1) upload selector which uses a CS REST API "versions" call to update the file on content server. I would like to trim this down the upload process if possible by utilizing the the CS REST API XMLHttpRequest and
XHR2 FormData which supports this. The trouble is that CS throws the "illegal attempt to upload a document". From the forums, it seems to be stuck on seeing the 'file' attribute. Is this possible at all?
Snippet:
// Create Blob
var text = document.getElementById("item12_textarea_1").value;
text = text.replace(/\n/g, ""); // To retain the Line breaks.
var blob = new Blob([text], { type: "text/plain"});
// Comment out Manual File Pick Call
// var file = $('#item11_file_1')[0].files[0];
var body = {
id: 4766535
};
formData = new FormData();
formData.append('fname','csx.txt');
formData.append('body', JSON.stringify(body));
formData.append('data',blob);
//Old Manual Call
//formData.append('file', file);
$.ajax({
url: "[LL_REPTAG_URLPREFIX /]/api/v1/nodes/4766535/versions",
beforeSend: function(xhr){xhr.setRequestHeader('OTCSTicket', [LL_REPTAG_OTCSTICKET QUOTE /]);},
method: "POST",
// data: formData,
processData: false,
contentType: false,
success: function(response) {
alert("Version Update Success.");
},
error: function(error) {
alert("Copying Template Failed.");
}
});
}