L
L
Luke Vost2014-12-09 19:47:41
JavaScript
Luke Vost, 2014-12-09 19:47:41

How to access a local file from a Chrome app?

I am writing an application for Chrome, I save the images added by the user to the database, or rather links to them, so that the user can continue working with them later. But the images are not displayed in the application window.
If you get the links in their pure form: "C:\Images\myjpeg.jpg" Chrome gives the following exception: "Not allowed to load local resource: C:\Images\myjpeg.jpg (if you add file:///, the situations will not change ). Ok, it turns out that you need to turn links into a File object, and then into a special URL object and then display, but for some reason this does not happen. It forms a link, it is attached correctly to img, but is not displayed.

var newURL = window.webkitURL.createObjectURL(new File([],"C:\Images\myjpeg.jpg",{type: "image/jpeg"}));

In theory, such a code should give the correct link to display in img, but am I missing something or not understanding correctly? Maybe the file object needs to be created somehow differently for createObjectURL()?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Taratin, 2014-12-09
@legbo

https://github.com/tantaman/LargeLocalStorage
Demo
tantaman.github.io/LargeLocalStorage/examples/album

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question