Search code examples
angularwysiwyg

@kolkov/angular-editor images upload Usage Guide


I am able to put Kolkov editor on my html page but it doesn't attach image on editor though it does upload file to mentioned url and I can see response params from server having a url to access uploaded file.

There is tutorial available to integrate it as compoent into angular project but couldn't find anything on how to deal with images.

If there are pointers in this regard, please help.


Solution

  • It uploads image using "file" paramater on upload REST API. So, on html

     <app-ngx-editor height="500px" minHeight="500px" [placeholder]="'Enter text here...'" 
    [spellcheck]="true"  [(ngModel)]="htmlContent" imageEndPoint="https://localhost:8500/upload">
          </app-ngx-editor>
    

    And on REST side,

    @PostMapping(path="/upload", produces = "application/json")
        @ResponseBody
        public Map FileUpload(@RequestParam("file") MultipartFile file, Model model) { 
    
            Map<String,String> values = new HashMap<String,String>();
            storageService.store(file);
            values.put("url", "http://localhost:8500/files/"+file.getOriginalFilename());
            return values;
        }