I have a model which I have uploaded to an AnyLogic private cloud. I have been successfully able to run it, pass inputs and retrieve outputs of my model with any issue. I am running this via a locally hosted web app
I have been trying to set up my model so the user can upload a .json file containing string inputs needed to run the model. Unfortunately I cannot get this to work. Currently I am testing with a json file containing the following:
{"testValue" : 123}
I have an html input element which is able to upload and pass a file to my javascript code:
<h2>Upload file</h2>
<div className="flex">
<input type="file" id="fileInput" onChange={handleFileUpload} style={{ position: 'relative', zIndex: 100 }}></input>
</div>
function handleFileUpload(event:ChangeEvent<HTMLInputElement>) {
const target = event.target as HTMLInputElement //target is the input element
if(target && target.files){
if(sim){
//function to upload file and then run an animated model
runAnimation(sim.anylogicModelId, runButtonId, runMonteCarloId, animationContainerId, target)
}
}
}
Code in runAnimation:
cloudClient.uploadFile(input)
.then((hash) => {
//console.log("set file name ", file.name)
inputFile = {fileName: file.name, resourceName: file.name, hash};
//console.log("inputfile ", inputFile)
});
the upload file method then runs the code to get the hash of the file I am uploading and then passes input.value to the api request to upload the file. This is where I am confused:
I have tried modifying the cloud client to pass in different objects to the upload-file request to see if I could get any different results
Here are the following things I have tried:
Not only do none of these work but the api request always returns an identical hash code for the uploaded file. It is always returned as a successful request and I am able to track it as far as the logs for the front end on my cloud. I have ran out of ideas on things to try at this point
I have not found any online examples of anyone who has used the javascript api for uploading files or any other questions asked about it. The only information is what is on the api page and in the cloudclient.js file. Has anyone here used this feature and are able to give me any more insight into how it works?