Downloading Poster image

A place for developers to advertise their TheTVDB.com enabled app and get help from other developers with the API.
westify
Posts: 1
Joined: Tue Jan 29, 2019 3:21 pm

Downloading Poster image

Postby westify » Tue Jan 29, 2019 3:50 pm

Hi,

I use a node.js server with the nest.js framework. In my service I try to download and save a poster image to my hard drive. I tried it via the swagger api and via postman and it works. But when I save it via my service I can't open the file but the binary code is in the file. So I think there is a parsing missing or something.

Code: Select all

this.getPosterFromTvDB(imageURL)
            .subscribe(resp => {
                let fileName = imageURL.toString();
                fileName = fileName.substring(imageURL.indexOf("/") + 1);
                this.writeImagesToDisk(fileName, JSON.stringify(resp.data) );
});


Code: Select all

writeImagesToDisk(imageName: string, image: any){
        fs.writeFile(API.PATH_TO_IMAGES + imageName, image, function(err){
            if(err){
                this.errorHandling(err);
                return;
            }
        })
    }