1

I currently have almost 500 image files in wwwroot/img folder. And my Git repository is bloated at the moment. I was wondering if there is a way to serve from another URL ?

I have another server where I can upload these images. A location like

www.anotherDomain.com/images

However, I want to serve the static files but by creating my own path.

As an example: What if I want to serve images from www.anotherDomain.com/images as www.myapp/admin/images, so I am not exposing www.anotherDomain.com/images ?

In startup.cs, I have done the following

            app.UseStaticFiles(new StaticFileOptions
        {
            FileProvider = new StreamConfigurationProvider( PhysicalFileProvider("www.anotherDomain.com/images"),
            RequestPath = new Microsoft.AspNetCore.Http.PathString("/admin")
          
        });

This is asking for an absolute path. Unfortunately, I can not map the network drive since the anotherDomain.com/images is hosted in an old VM (where I intend to upload all images) and my application is hosted on Azure App Service.

Shezi
  • 1,352
  • 4
  • 27
  • 51
  • One solution the problem of the images bloating the Git repo is to tell git to ignore the folder they are in. You can learn more about that here: https://stackoverflow.com/questions/343646/ignoring-directories-in-git-repositories-on-windows – RonC Dec 01 '22 at 18:42

0 Answers0