How long does a Blob persist?

前端 未结 1 2014
青春惊慌失措
青春惊慌失措 2021-01-01 17:52

I\'m trying to write a fail-safe program that uses the canvas to draw very large images (60 MB is probably the upper range, while 10 MB is the lower range). I have discovere

相关标签:
1条回答
  • 2021-01-01 18:40

    Blob URL can last across sessions? Not the way you want it to.

    The URL is a reference represented as a string, which you can save in localStorage just like any string. The location that URL points to is what you really want, and that won't persist across sessions.

    When using URL.toObjectUrl() in conjuction with the autoRevoke argument, the URL will persist until you call revokeObjectUrl or "till the unloading document cleanup steps are executed." (steps outlined here: http://www.w3.org/TR/html51/browsers.html#unloading-document-cleanup-steps)

    My guess is that those steps are being executed when the browser session expires, which is why the target of your blobURL can't be accessed in subsequent sessions.

    Some other discourse on this: How to save the window.URL.createObjectURL() result for future use?

    The above leads to a recommendation to use the FileSystem API to save the blob representation of your canvas element. When requesting the file system the first time, you'll need to request PERSISTENT storage, and the user will have to agree to let you store data on their machine permanently.

    http://www.html5rocks.com/en/tutorials/file/filesystem/ has a good primer everything you'll need.

    0 讨论(0)
提交回复
热议问题