question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot upload media

See original GitHub issue

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

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:8

github_iconTop GitHub Comments

4reactions
stevecode21commented, Dec 10, 2021

Hi. For everyone who is facing this problem for me worked after adding “s” to http: https://mywebsite.com

0reactions
azizfcbcommented, Oct 5, 2021

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

WordPress Can't Upload Images? Here's How to Fix It
Issues Uploading Images to Your Media Library · 1. Go to the /wp-content/ folder after connecting to your website through FTP. · 2....
Read more >
How to Fix the WordPress HTTP Error (Uploading Image to ...
The WordPress HTTP error occurs when something goes wrong while attempting to upload images or videos using the built-in media library tool.
Read more >
How to Fix Image Upload Issue in WordPress (Step by Step)
The image upload issue in WordPress is typically caused by incorrect file permissions. Your WordPress files are stored on your web hosting ...
Read more >
Android - Photos - Album - "Error, couldn't upload media"
Tap the system Settings tab on the main screen of your device. · Tap the General section of settings that is on the...
Read more >
Cannot upload file to media library: Unexpected response ...
I am unable to upload certain files to my website's media library, a 1.8mb pdf file in this case. It returns this error:...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found