(for context I need the documents byte stream in order to save it to blob storage but I also need it done in a context where I can get access to other relevant data like database ids)
I am using the sample MVC sample project.
I could either do the work client side in the browser or using c# in the controller.
Client Side
The problem with the client side is the JavaScript library does not give access to the saved file's byte array. The Save method in 'docuvieware-min.js' called by the DocuViewareControl generated UI simply takes the FileResult from the MVC controller's save action and set's it to 'window.location'. I could override this but since it is an internal method it stands the chance of being overwritten with future Docuvieware software updates. My expectation would be that the 'onDocumentSaved' event would provide a data object with the updated file details in it but it does not.
Code: Select all
//I wish I had access to the file object as part of the response
window.location = a.appControllerPath + "/save" + (a.useIdInRoot ? "/1" : "") + "?sessionID=" + this.ajax.sessionID + "&fileName=" + encodeURIComponent(b) + "&format=" + d + "&pageRange=" + (e ? e : "*");
...
if (a.callbacks.onDocumentSaved)
a.callbacks.onDocumentSaved(); //I would expect onDocumentSaved passes back the result of the save action
The problem with server side is I have no context about any of the document's meta data. In particular, what database record it is related to. When a document is annotated and saved I need to verify access rights, update a database record, then save the document to storage. I do not see a way of passing additional data with the save command so that I could do this operations from within the action. If I could pass the database id along with the save request I would have everything I needed to complete the operation.
Code: Select all
//I do not see a way of passing in or accessing any data other than what is directly supplied by the Docuvieware libraries
public IActionResult Save(string sessionID, string fileName, string format, string pageRange)
{
DocuViewareControllerActionsHandler.save(sessionID, ref fileName, format, pageRange, false, out HttpStatusCode statusCode, out string reasonPhrase, out byte[] content, out string contentType);