'Angular 10 - Local Server File and Symlink

I have an image upload utility in my Angular Application. Every files uploaded by users are stored in

/var/lib/application_name 

because its the only folder owned by www-data (Apache user).

My problem is showing these images.

  1. I cannot mound any apache point to this folder;

I'm actually using this Backend ViewSet to load images and return a blob. settings.DATA_DIR is my /var/lib/application_name:

@action(detail=False, methods=['get'])
def get_file(self, request):
    sub_dir         = request.query_params.get("s")
    filename        = request.query_params.get("f")
    logo_path       = os.path.join(settings.DATA_DIR , sub_dir , filename)
    logo_image      = open(logo_path, 'rb')
    return HttpResponse(logo_image, content_type="image/png")

I want a View that return only a URL like: /assets/logos/myuploadedlogo.png

Unfortunally I cant connect builded assets to a local folder. I've tried to use symlink in assets and the option

"preserveSymlinks": true

but the symlink is not created in dist directory.

PS. This is my development build:

 "development": {
              "buildOptimizer": false,
              "optimization": false,
              "vendorChunk": true,
              "preserveSymlinks": true,
              "extractLicenses": false,
              "sourceMap": true,
              "namedChunks": true,
              "outputHashing": "all",
              "extractCss": true,
              "aot": true,
              "budgets": [
                {
                  "type": "initial",
                  "maximumWarning": "30mb",
                  "maximumError": "30mb"
                }
              ]
            }


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source