Open Yoric opened 11 years ago
Thank you for opening this issue. Do you have any documentation or example about how to implement a Device Storage to access a file? My internet searches are unsuccessful...
Thank you it helps!
Do you know it's possible to test a Device Storage without a phone?
I haven't tested it myself, but the code to do so exists in Desktop and Android Firefox.
I was not able to use device storage in desktop Firefox (no idea about mobile). I had to use the Firefox OS simulator to test it: http://people.mozilla.org/~myk/r2d2b2g/
This is what i did to, but how can i add some files into "pictures" or musics"? There are actually no files in there.
I'm pretty sure they map to your ~/Picture and ~/Music directories on OS X and Linux, and c:\Users[username]\Pictures and c:\Users[username]\Music on Windows.
Great! Thank you!
All the details are here, if you feel inclined to search the C++ source code of Firefox/FirefoxOS.
I'm having some difficulties to implement DeviceStorage. I use the storage "music" and "pictures" but those storages only specific format. Jpg. Png for "pictures". Mp3 for "music"). Storage device does not recognize .epub files
I'm trying to view files using this code:
var storage = navigator.getDeviceStorage ("pictures");
if (storage) {
var = booksCursor storage.enumerate ("books");
var i = 0;
booksCursor.onsuccess = function (e) {
var book = booksCursor.result;
console.log ('cursor' + i);
console.log (book);
console.log (book.name);
DisplayIndex (book);
i + +;
booksCursor.continue ();
};
booksCursor.onerror = function (e) {
alert (booksCursor.error.name);
};
}
function DisplayIndex (book) {
var list = document.getElementById ('books');
var li = document.createElement ("li");
li.textContent = book.name;
list.appendChild (li);
}
This displays to me all files except .epub in the directory "books".
That doesn't sound good. You should ask on irc.mozilla.org, #openwebapps.
On 3/18/13 2:38 PM, Tony wrote:
I'm having some difficulties to implement DeviceStorage. I use the storage "music" and "pictures" but those storages only take into account the specific files to storage (. Jpg. Png for "pictures". Mp3 for "music"). Storage device does not recognize the files. Epub.
I'm trying to view files using this code:
var storage = navigator.getDeviceStorage ("pictures");
if (storage) {
var = booksCursor storage.enumerate ("books"); var i = 0;
booksCursor.onsuccess = function (e) { var book = booksCursor.result; console.log ('cursor' + i); console.log (book); console.log (book.name); DisplayIndex (book); i + +; booksCursor.continue (); }; booksCursor.onerror = function (e) { alert (booksCursor.error.name); }; }
function DisplayIndex (book) { var list = document.getElementById ('books'); var li = document.createElement ("li"); li.textContent = book.name; list.appendChild (li); }
This displays to me all files except .epub in the directory "books".
— Reply to this email directly or view it on GitHub https://github.com/jbarbin/EPub-Reader/issues/13#issuecomment-15054963.
Good news: you should not need this anymore.
FirefoxOS should be able to handle <input type="file">
within a few days.
Yes!! That's a really good news!
Good news: <input type="file">
now works.
Bad news: it won't let me pick your books just yet. You (or someone else) still need to write a small application to open ebooks :/
Unfortunately,
<input type="file">
doesn't work yet on FirefoxOS. You will need a non-trivial workaround to be able to open files on FirefoxOS.Detect whether
<input type="file">
is supportedSomething along the lines of
If it is not supported, call a web activity
Web Activities are a mechanism to let one application request data from another application. If
<input type="file">
is not supported, the best way to request a file is to launch Web Activitypick
with type“application/epub+zip”
. This will let any application that can pick such files handle the task of opening the file.Implement your own web activity for opening a book
... unfortunately, for the moment, there are no such applications, so you will have to implement one using Device Storage to access the file. You should probably use device storage
"pictures"
, for the lack of a better device storage.