Error In Set Url Blob
Closed this issue · 6 comments
core.js:6185 ERROR Error: Uncaught (in promise): TypeError: this.url.indexOf is not a function
TypeError: this.url.indexOf is not a function
at NgxDocViewerComponent. (ngx-doc-viewer.js:141)
at Generator.next ()
at tslib.es6.js:74
at new ZoneAwarePromise (zone-evergreen.js:960)
at __awaiter (tslib.es6.js:70)
at NgxDocViewerComponent.ngOnChanges (ngx-doc-viewer.js:97)
at NgxDocViewerComponent.wrapOnChangesHook_inPreviousChangesStorage (core.js:26853)
at callHook (core.js:4690)
at callHooks (core.js:4650)
at executeInitAndCheckHooks (core.js:4591)
at resolvePromise (zone-evergreen.js:798)
at new ZoneAwarePromise (zone-evergreen.js:963)
at __awaiter (tslib.es6.js:70)
at NgxDocViewerComponent.ngOnChanges (ngx-doc-viewer.js:97)
at NgxDocViewerComponent.wrapOnChangesHook_inPreviousChangesStorage (core.js:26853)
at callHook (core.js:4690)
at callHooks (core.js:4650)
at executeInitAndCheckHooks (core.js:4591)
at refreshView (core.js:11814)
at refreshDynamicEmbeddedViews (core.js:13154)
Hi @moondoan, could you provide more information? Do you set url with a blob. Because that is not supported.
I am also getting a similar error. I get a blob from the server, and then I convert the blob to a Base64 dataURL using FileReader.
The file type in my case can either be .pdf
or .docx
. The documents are not publicly available, so I'm using one of the viewers [pdf, mammoth] depending on the file type.
If I use the Base64 dataURL as is (without sanitizing), it works (both .docx and .pdf are displayed correctly), but it also throws an error for .pdf files unsafe value used in a resource URL context
.
If I try to bypass security by using DomSanitizer and passing a safe URL instead, it no longer works.
Hi @mediantiba,
Are you saying that the only problem an console the error: unsafe value used in a resource URL context
for pdf files, but they are displayed correctly? I'll check if it maybe intially is loaded with an 'unsafe' empty url or something.
@Marcelh1983 Yes, exactly, I get that error in the console in the case of .pdf even though it still renders correctly on the screen. I get no errors in the case of mammoth viewer. If I try to sanitize the input, it no longer works in either case.
In my application, I've temporarily solved the problem by using an object
tag to display pdf files.
<object
*ngIf="type === 'pdf'"
[data]="data | safe: 'resourceUrl'"
type="application/pdf"
style="width: 100%; height: 80vh;"
></object>
Looking at the source code, I see you're using an embed
tag to display pdf.
https://stackoverflow.com/questions/1244788/embed-vs-object
It seems here that using the object
tag is the preferred way.
Thanks @mediantiba,
I changed the tag. If you use the pdf option only I would advice to just use the object tag instead of using this package :) but if you have several formats you can load them in this viewer with different viewer types.
I'm closing this issue, @moondoan if you still have issues with the viewer please let me know.
Thanks again!