Reputation: 4554
I need help with sending a file from a browser to another device that is connected to a machine that is running a server. I'm new to web application programming as well as back-end programming.
The existing code can move a file that exists on the server to the device by calling the web API as follows - http://localhost:3333/api/Install_Job_to_device/filename.zip..
The existing server-side code is also capable of receiving a file from the browser.
Now I want the browser code to call the API http://localhost:3333/api/Install_Job_to_device/filename.zip once the filename.zip file is uploaded to the server, so that it gets transferred to the device.
The current code which uploads file to the server is below. Can you please suggest how to make the Web API call from here ?
<h3>File Upload:</h3>
Select a file to upload: <br />
<form action="../api/RdaServer" method="post"
enctype="multipart/form-data">
<input type="file" name="file" size="50" />
<br />
<input type="submit" value="Upload File" />
</form>
Upvotes: 0
Views: 102
Reputation: 431
Looks like you are almost done.
If both of the code (uploading to server and push to device works), you can consider the following options:
Option 1: (Making changes to your upload API)
Make changes to your upload webAPI such that it calls the corresponding webAPI (http://localhost:3333/api/Install_Job_to_device/filename.zip..) to push the file to the device instead of modifying your web request in the html you provided.
Option 2: (Making two web requests)
You have make slight changes to your upload webAPI to return an acknowledgement when the file upload is successful. From there, you create another web request and call your pushing webAPI to deliver the file to your device.
Have fun programming! Cheers!
Upvotes: 1