you can do that with the function wp_handle_sideload
https://developer.wordpress.org/reference/functions/wp_handle_sideload/
Steps to make this :
- create a temporary file with the content you need
- pass this filename to function
wp_handle_sideload
you can do that with the function wp_handle_sideload
https://developer.wordpress.org/reference/functions/wp_handle_sideload/
Steps to make this :
wp_handle_sideload