Coder Social home page Coder Social logo

hylyh / node-mastodon Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ttezel/twit

98.0 98.0 5.0 897 KB

Mastodon API Client for node

Home Page: https://www.npmjs.com/package/mastodon

License: Other

JavaScript 100.00%
mastodon mastodon-api mastodon-social-network

node-mastodon's Issues

support custom headers

Would be great if we could pass custom headers. For example, 'Idempotency-Key' for statuses.

Perhaps this would be possible if we pass path as an object i.e.
{ path: 'statuses', headers: { 'Idempotency-Key': '<whatever>' } }

upload errors

for some reason ~70% of the time i submit a media post, i get a missing image as the result.

my code

      if (!is.bad(img)) {
        console.log(`file exists: ${fs.existsSync(img)}`)
        const res = await M.post('media', {
          file: fs.createReadStream(img)
        })
        console.log(JSON.stringify(res.data))
        out.push(res.data.id)
      }

the result

stream: ./img/upload_wikimedia_org_wikipedia_commons_5_5d_Pan-bagnat_1_jpg.jpg
file exists: true
result: {"id":"72087","type":"unknown","url":"https://bofa.lol/files/original/missing.png","preview_url":"https://bofa.lol/files/small/missing.png","remote_url":null,"text_url":"https://bofa.lol/media/xgv6Lhvuj4gzXWcY3w4","meta":null,"description":null}

Invalid image file after upload

I get an image that is invalid every time I upload through the API, but looks to be fine on my computer. I'm using Pleroma for my instance, and the following code to upload my image.

            event.api.post('media',{
                file: fs.createReadStream("./tmp.png")
            }).then(resp => {
                console.log(resp.data.id + " " + resp.data.url)
            }).catch(err => {
                console.log("[ERROR]\t" + err.message);
            });

Here's one of the resulting uploads: https://lasershark.army/media/348b4ea0-9858-4b61-a205-04f7ebcb132d/tmp.png

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.