0

I have an application with symfony 5 in back and angular in front.

The app was working fine a few years ago but now I have a problem on loading a file only on Safari.

I think the createObject URL function no longer works on safari but I don't know how to replace it.

Here is my typescript file which displays the document :

import {Injectable} from '@angular/core';
import * as FileSaver from 'file-saver';
import {Subject} from 'rxjs/Subject';

@Injectable()
export class DocViewService {

    public displayLink$;

    private displayLinkSource = new Subject<string>();

    constructor() {
        this.displayLink$ = this.displayLinkSource.asObservable();
    }

    changeLink(link: string) {
        this.displayLinkSource.next(link);
    }

createLink(blob: any, suffix: string) {
        // remove suffix if browser if safari
        if(navigator.userAgent.toLowerCase().indexOf('safari') !== -1){
            this.changeLink(URL.createObjectURL(blob));
        }else{
            this.changeLink(URL.createObjectURL(blob) + suffix + '&zoom=75&toolbar=0');
        }
}
    saveLink(blob: any, name: string) {
        FileSaver.saveAs(blob, name);
    }
}

Do you have an idea please?

oracle972
  • 77
  • 10

0 Answers0