1

My js Code, My HTML File

Simple input field for file

const input= document.getElementById("file")

input.addEventListener("change",My)

 function My(e){

const file= e.target.files[0]

const blob= new Blob([file])

const url= URL.createObjectURL(blob)

console.log(url)

}

when I create a Blob Link then it is successfull created blob link and also show the blob link content( only current tab or current browser window) but problem occur when I use this blob link to incognito mode then it give error, Blob Link are blocked and also occur this problem when refresh the current browser window.

How to tackle this problem?

Dave Newton
  • 158,873
  • 26
  • 254
  • 302
hydraCode
  • 77
  • 10
  • Do you have extensions such as adblockers that are enabled in incognito? Can you share the full error message w/ the trace? – JBallin Jun 08 '22 at 16:28
  • Does this answer your question? [Open blob objectURL in Chrome](https://stackoverflow.com/questions/43283454/open-blob-objecturl-in-chrome) – JBallin Jun 08 '22 at 16:30
  • You may need to set the type in the `createObjectURL` or `new Blob` call. – Dave Newton Jun 08 '22 at 16:30
  • after give the type, still same error – hydraCode Jun 08 '22 at 16:36
  • Not sure what you mean by "*show the blob link content*". Are you trying to open the logged url in a new tab? – Bergi Jun 08 '22 at 16:51
  • yes, I was try to open a new tab. but it is give this error – hydraCode Jun 08 '22 at 19:22
  • Don't do that, that's not what object urls are designed for. – Bergi Jun 08 '22 at 19:49
  • The `blob` link is a temporary link, if you refresh the page it will lost. Although you can open it in a new tab of the same browser, but not support opening it in incognito mode. – xgqfrms Aug 29 '23 at 21:03
  • The reason is in incognito mode or a different browser, the `blob` link will lose its `referer` or some cookie message. – xgqfrms Aug 29 '23 at 21:05

0 Answers0