2

I'm trying to get a pdf file displayed on my page. The pdf file is located as a blob on azure. I'm getting the link to the blob itself from the server, that way i can grab the file directly from the storage instead of passing it through the server.

I set up a shared access signature(SAS key) because the container is protected.

Since I'm using angular 5 I need to sanitize my url which i'm doing.

 this.http.get(baseUrl + 'api/download/fileuri?sheetId=' + this.sheetId, { responseType: 'text' }).subscribe(result => {
        this.url = result.toString();            
        this.sanitizedUrl = this.sanitizer.bypassSecurityTrustResourceUrl(this.url);
        console.log(this.sanitizedUrl);
    }, error => console.error(error));

I'm then putting it inside a object, yet i either get nothing but a white page or i get the following error.

<object [data]="sanitizedUrl" type="application/pdf" style="width:100%; height:100vh"></object>

enter image description here

I set up the following in azure:

enter image description here

The weirdest part is: I can grab that file but just inputting that link, it just starts downloading it. But the moment i try to access it from the object, it throws that error. So the link is correct and it works. It's just whenever i try to access it from within the page..

2
  • 1
    You need to enable CORS for your blob Commented Nov 8, 2018 at 11:25
  • I did, the last picture is of the storage account CORS. I allowed all traffic to go through by putting in * to make sure that would not block it for testing Commented Nov 8, 2018 at 11:57

1 Answer 1

1

I recommend you to download Microsoft Azure Storage Explorer. Inside of it you can set CORS policy for specific resource. I hope it will solve your problem.

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.