Link to home
Start Free TrialLog in
Avatar of Andy Green
Andy GreenFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Getting an image from an on premise server to the WWW with an API

Hi, looking for somewhere to start here.

We have an API with an on premise portion, and need to get images from the on premise server through a few hoops and hops out to the www to display in a browser.

Currently we are encoding the images and sending that in the JSON payload, but is there a way (caching for example) where we can serve up the image as a URI, without copying the images to the on prem / www interface.

The on premise server is secure and we are using OAuth2 and openID to bounce down through the layers.

Andy
ASKER CERTIFIED SOLUTION
Avatar of David Favor
David Favor
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of dpearson
dpearson

I think the key term you are looking for is "proxying".  You want your public facing web server to act as a proxy, taking the request for the image and then pulling the file from the internal server and serving it up as if the image had been sitting on the web server all along.  The client making the request can't tell the difference, it just knows it asked for https://yourdomain.com/file.png and the data arrived.

Exactly how you do that depends on the web server you are using (and since you mention asp.net it's likely a Windows server which I personally know nothing about), but acting as a proxy is a standard concept and you should be able to just look up how to set that up for your web server.  You don't want to proxy an entire server (that's different) you just want to proxy a URL.  It will just need to know how to authenticate to your internal server.

Hope that helps,

Doug
I would create a scheduled task on my local server that ftp's to the public.  if you keep the folder structure locally the same as online, that should be easy.

If you created a ps1 file to perform the upload https://techexpert.tips/powershell/powershell-upload-files-ftp-server/

Then a scheduled task to run the ps1 file https://blog.netwrix.com/2018/07/03/how-to-automate-powershell-scripts-with-task-scheduler/

You can create the schedule in powershell instead of task scheduler, but I found it hard to track. That could be been du to my own lack of knowledge, but with the scheduler, you have the GUI and can view what happened with each time it runs.
Avatar of Andy Green

ASKER

Thanks guys, some good stuff here. Have to use OAuth as its NHS over N3, FTP is a solution I've had a look at, but discounted over timings of uploading new images, but will re visit. Dont know anything about Proxying so that will be cool to investigate.

Thanks Guys.
Hopfully shard the credit.
FTP is a poor choice of words out of old habits. You can use your server-side language of choice to upload your image to your server. https://docs.microsoft.com/en-us/dotnet/api/system.web.ui.webcontrols.fileupload.saveas?view=netframework-4.8  You can add to that where the server is looking for OAuth and even encrypt it on the client and decrypt on the server.  

Once you have the client and server code deployed, use task manager to schedule the files to be upload.
Thanks for clarification Scott.

Andy