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.

image upload not working

See original GitHub issue

Hi there,

I can’t make this snipped work

const Twitter = require('twitter-lite')

var client = new Twitter({
  consumer_key: 'changed',
  consumer_secret: 'changed',
  access_token_key: 'changed',
  access_token_secret: 'changed'
})

var data = require('fs').readFileSync('./mymedia.png')

client.post('media/upload', { media: data })
  .then((err, media, res) => {
    console.log(err, media, res)
  })

The only thing i got is err = { errors: [ { message: 'Sorry, that page does not exist', code: 34 } ] }

Did I miss something ? I’m on a macOS with nodejs v9 and the latest version of this lib. Uploading the same image with twurl works like a charm.

Thanks

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
Djiitcommented, Apr 20, 2018

Might be related to the fact that the media/upload endpoint is on the ‘upload’ subdomain, not the ‘api’ one.

3reactions
insanity54commented, Feb 16, 2021

There’s a good example of creating two clients in the test suite, while keeping it DRY. One for api endpoint, one for upload endpoint.

function newClient(subdomain = 'api') {
  return new Twitter({
    subdomain,
    consumer_key: TWITTER_CONSUMER_KEY,
    consumer_secret: TWITTER_CONSUMER_SECRET,
    access_token_key: ACCESS_TOKEN,
    access_token_secret: ACCESS_TOKEN_SECRET,
  });
}

then you can do–

const uploadClient = newClient('upload');
const apiClient = newClient();
Read more comments on GitHub >

github_iconTop Results From Across the Web

php - Image upload not working - Stack Overflow
I would consider myself an intermediate PHP programmer, but I have never used file uploads before. I have been stuck on this problem...
Read more >
What is Wrong With a Computer When Your Pictures Won't ...
Close your browser window and clear your cache and cookies and reload the site. You'll join another server that may work more quickly...
Read more >
6 Easy Ways to Fix Image Upload Issues in WordPress
In some cases, disabling the plugins you are using can also resolve the image upload issues. Disable all the plugins you have incorporated....
Read more >
How to Quickly Fix Image Upload Issues in WordPress
2 Common WordPress Image Upload Errors and Solutions to Fix Them ; 2.1 Change File Permissions ; 2.2 Rename the Image ; 2.3...
Read more >
How to Fix Image Upload Issue in WordPress (Step by Step)
If the issue is cropping up after transferring a site to a new domain this works for me: open the Settings menu, and...
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