You need to create a new POST route inside the routes/media.js file that you can use to manage your media. According to the documentation , you need to pass four items:
The file you want to upload, which you pass as form data.
Upload file type, which you generate using the helper function.
Messaging product, which you get from the .env file.
When you create an API call, though, you only need a phone number ID and file. The remaining fields you generate using the helper functions.
You use the npm package formidable to process the form data. Note that the WhatsApp iran mobile database Business API has some limitations on specific types and sizes, which you can find in the Supported Media Types section at the bottom of the Media documentation . There are two helper functions inside the helper/validations.js file in the skeleton project to cope with that.
To upload an image, you need to initialize a new formidable form. Using the form object, parse the file and perform some validations using the helper functions. Next, perform a POST request with form data and a valid authentication token using the request.
Phone number ID, which you pass as a parameter
-
- Posts: 461
- Joined: Mon Dec 23, 2024 5:30 am