shah / uniform-resource

Uniform resource transformers for content orchestration engines
GNU Affero General Public License v3.0
1 stars 0 forks source link

Article Image #3

Closed ratheesh-kr closed 4 years ago

ratheesh-kr commented 4 years ago

Need to fetch the article image with the curated content.

shah commented 4 years ago

A reference to the article image is already available for websites with OpenGraph or Twitter social graph data. If those aren't present, then both Mercury Readable or Mozilla Readability also have them. Let me know if one of those will work or if you're thinking about something else. Please add in specific details about how to retrieve the image and whether you need just the URL or the image binary (both are possible).

ratheesh-kr commented 4 years ago

Thanks @shah for the response.

Open project API needs image binary for saving the image with the curated content. It is OK to get the Image URL also because we convert the URL image to binary in the data provider.

Using the uniform-resource library we are taking the image URL and the data provider converts that in to binary to save the data in Open Project.

shah commented 4 years ago

Sounds good @ratheesh-kr - does that mean you do not need any changes/enhancements to uniform-resource and you're doing the work some other way? Or, do you need functionality added to uniform-resource to help with this task?

ratheesh-kr commented 4 years ago

Thanks @shah for the response

Yes, there is no need for any changes and enhancements to uniform-resource for fetching and storing the article images with the curated content.

vprdnew commented 4 years ago

Hi @shah We are sending the binary image to API where the content is stored. The binary image data will be good to show on for the showing by avaoiding call from browser and that will also avoid the CORS issue in some resources.

app.post('/api/toBase64', function (req, res) {
    const requestObject = require('request').defaults({ encoding: null });
    requestObject.get(req.body.url, function (error, response, body) {
        if (!error && response.statusCode == 200) {
            const data = "data:" + response.headers["content-type"] + ";base64," + Buffer.from(body).toString('base64');
            res.end(data);
        } else {
            res.end(JSON.stringify(resObj));
        }
    });
});

The above is a working code which used curently to conver image to base64 format and return.

shah commented 4 years ago

The initial version of image downloading is now in version 0.8.0 of this package - please take a look and create new tickets for new requirements.