Question Details

Answered
Imagemap - Image hosting

Dear all,

Can I have a further question regarding imagemap? I know teh restful API endpoint will be requried for imagemap, and the endpoint should be like this: https://example.com/images/cats/1040

Do you have any ideas on how to host images and expose the images as rest API endpoint like above? any existing service/cloud can be used for quick start?

Any suggestions would be very helpful!

Michael

0
Profile picture
Tester

Answers

1
Profile picture
Tester
Posted: 1 years ago
Edited: 1 years ago

OK, seems nobody has solutions or experiences. Let me share my solution here in case that you guys has simialr requirement. I beleive you should have same requriement if you use Line massasge API.

1. Create Node.js project 2. Import express and start a simple server

app.listen(process.env.PORT || 8080, () => {
  console.log('@==LineImageAPI==@ server is running at ' + process.env.PORT || 5000);
});

3. Provide a rest api for fetching images from the server like bwlow:

app.get('/image/:category/:size', (req, res) => {
 const requestedCategory = req.params['category'];
 const requestedSize = req.params['size'];
 res.type('image/jpeg');
 fs.createReadStream('public/images/' + requestedCategory + '/' + requestedSize + '.jpg').pipe(res);
});

4. Place your images into the root libelow structure:

root-public-images-[category]-460.jpg
root-public-images-[category]-700.jpg
root-public-images-[category]-1040.jpg

5. Deploy your express to aws, google or other servers you have.

6. Access to https://yourdomain.com/image/product/1040, then you should get the image from browser or postman.

7. Copy the https://yourdomain.com/image/product to your linebot source code for imagemap object - baseUrl. You do not need to specify the size here for rest api, as line will use the proper size of images for you automatically.

Finally, AWS S3 proxy might be a good idea but I did not get it done as of now. anybody else could share your experience if you made it succefully.

Thanks.

Michael

Are you sure? question.vm