hylyh / node-mastodon

Mastodon API Client for node

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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Invalid image file after upload

CorruptMonkey opened this issue · comments

commented

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

commented

After further inspection I found that the image file was in fact being saved wonky and that even though it looked fine on my computer something about it didn't work after it was uploaded. I was able to get it working after some more toying around with how I was saving my image.