In this tutorial, we will learn to browse an image from our local machine, show it in a browser, and finally, save it by calling API. We will pass image data as JSON through API.
Coding flow - First browse images in our main component. Then pass that image data to a callback function. The callback function calls an API service with the API address and image data. Finally, the API service will call API and pass image data as a JSON parameter.
Given below is the flow of our coding.
Code Architecture |
Step 1. Browse Image: First, we browse images from the local machine and show that in a browser.
Step 2. Image Process: After clicking on "Save Image" button -
- Start image data read and set on 'selectedImage' variable
- Load a model with that image data
- Finally call a callback function to save the image data
Step 3. The callback function just converts the model to JSON data. And call API service and provide
API address and request parameter as JSON.
Step 4. Finally, the API service calls API with JSON data to save in DB.
Done 👍 (Contact for code, if required)
0 Comments