Storing the Image fetched from url

I'm getting a image URL as a result of API call. I need to store the image upon fetching the image from URL. how can I store the image such that I can replace the actual image URL with my URL which will be fetched dynamically whenever user opens the page.  In order to store these images what are my options? (Note: For now, there are images but later it can be different types of files may be videos.)
1 answers

In the community commons module there is a java action available for this: storeURLToFileDocument

I think this will help you implement your requirement.