How to Download Images from Different Rails Application Sharing a Session?
We have been working on a large Ruby on Rails SAAS application which is made up of few microservices, all written on Ruby on Rails. Few of the microservices are used to generate a composite view and so required to share session with the front application.
One of the microservice extracts all the images from the html generated by other microservice, downloads images and upload to different CMSes.
We are big fan of Service Object pattern and written service objects to handle downloading images from different sources and upload to configured CMSes. Now challenge here is service classes are PORO and doesn’t know about session management across different apps. So downloading an image is not as easy as
So here comes Mechanize to rescue. All you have to do is passing a session cookie before making request to download the image. Here is a small snippet to get that done.
At BoTree Technologies, we build enterprise applications with our RoR team of 25+ engineers.
Consulting is free – let us help you grow!
Choose Your Language
- Digital Marketing
- IT Consulting
- Project Management