Displaying Pdf from azure blob storage
up vote
2
down vote
favorite
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>
I set up the following in azure:
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..
angular azure azure-storage
add a comment |
up vote
2
down vote
favorite
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>
I set up the following in azure:
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..
angular azure azure-storage
1
You need to enable CORS for your blob
– user184994
Nov 8 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
– SNIPEZ
Nov 8 at 11:57
add a comment |
up vote
2
down vote
favorite
up vote
2
down vote
favorite
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>
I set up the following in azure:
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..
angular azure azure-storage
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>
I set up the following in azure:
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..
angular azure azure-storage
angular azure azure-storage
edited Nov 8 at 13:09
Chamila Maddumage
102113
102113
asked Nov 8 at 11:23
SNIPEZ
345
345
1
You need to enable CORS for your blob
– user184994
Nov 8 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
– SNIPEZ
Nov 8 at 11:57
add a comment |
1
You need to enable CORS for your blob
– user184994
Nov 8 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
– SNIPEZ
Nov 8 at 11:57
1
1
You need to enable CORS for your blob
– user184994
Nov 8 at 11:25
You need to enable CORS for your blob
– user184994
Nov 8 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
– SNIPEZ
Nov 8 at 11:57
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
– SNIPEZ
Nov 8 at 11:57
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
accepted
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.
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
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.
add a comment |
up vote
1
down vote
accepted
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.
add a comment |
up vote
1
down vote
accepted
up vote
1
down vote
accepted
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.
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.
answered Nov 8 at 11:59
Mateusz Wyczawski
513
513
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53206761%2fdisplaying-pdf-from-azure-blob-storage%23new-answer', 'question_page');
}
);
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
1
You need to enable CORS for your blob
– user184994
Nov 8 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
– SNIPEZ
Nov 8 at 11:57