My developer is trying to upload media through the rest API to the media library in batch, as we have thousands of files and making a request for each one takes too much time.
But it doesn’t seem to be possible… Is it?
def upload_image(files):
media_endpoint = f'{settings.BASE_WOOCOMMERCE_API}/wp-json/wp/v2/media’
# Send a POST request to upload the image
response = requests.post(url=media_endpoint,
auth=(settings.WP_USER, settings.WP_PASSWORD),
files=files)
print(response)
files is something like this
files = [(‘file’, open(‘report.xls’, ‘rb’)), (‘file’, open(‘report2.xls’, ‘rb’))]
Only one image gets uploaded…
[ad_2]