简体   繁体   中英

Remotely upload a file to Wordpress from nodejs instance

I'm running a node app on Heroku. It gathers a chunk of data and sticks it into a set of JSON files. I want to POST this data to my Wordpress server (right now it's on siteground, but moving to WP Engine).

I thought the WordPress REST API would provide what I wanted but after reading the docs I'm not not so sure.

Does anyone have any advice on this? It's not the kind of thing I've done before.

Naturally, I could download the generated files and manually upload them in the right place… but I want it to be automated!

Can anyone point me in the right direction?

Looked at WordPress REST API but don't think that's the answer.

An option would be to setup a cron job on your Wordpress site to download the already made JSON files. This would let you download the files via http if they're publicly available, or using an api-key, or SFTP even.

You could also go the opposite way and setup a cron job on the server running your node app and use SFTP to deliver the updated files onto your Wordpress site.

If you are really committed to wanting to use the wordpress rest api, I think the closest one that comes to my mind (not an expert in wordpress) would be that you'd upload the json files as media objects: https://developer.wordpress.org/rest-api/reference/media/ .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM