node-wpapi
node-wpapi copied to clipboard
Cannot upload media
Environment
nodejs: 10.14.1
wpapi: ^1.2.1
Step to reproduce
Attempt the following code:
const WPAPI = require('wpapi');
var wp = new WPAPI({
endpoint: 'https://www.mysite.com/wp-json',
username: "my_username",
password: "my_password"
})
wp.media()
// Specify a path to the file you want to upload, or a Buffer
.file( 'path/to/file.jpg' )
.create({
title: 'My awesome image'
})
.then(res => {
console.log(res)
})
Expected result
New media would be uploaded
Actual result
All existed media is returned
Just to confirm, do you have the Basic Auth plugin installed and active?
I was using Basic Auth for testing the API.
Same problem here, any updates or solutions?
same issue here
same for me. Just try to reproduce the example and got an error, don't know if you got the same error ?
Failed to execute 'append' on 'FormData': parameter 2 is not of type 'Blob'.
@Cchumi Had the same issue. The media file must be uploaded from a nodejs server. It won't work out of the box via Reactjs, at least from my experience.
Works properly on WP5.4 but had the same problem mentioned here on WP4.7.3. I think this is related to WordPress version being targeted
Hi. For everyone who is facing this problem for me worked after adding "s" to http
: https://mywebsite.com