evanshortiss / html5-fs

Node.js style wrapper for the HTML5/Cordova FileSystem API
16 stars 7 forks source link

How can I open a file by cdvfile:// url ? #6

Closed Satyam closed 7 years ago

Satyam commented 7 years ago

I want to use this library to allow an MP3 tag reader to read the tags on music files already in the filesystem, not manipulate newly created files on my own storage area. I can easily access the files using the native FileSystem by giving it a cdvfile: or file: url , but the MP3 tag reader (and several other utilities I need) expect a node fs interface.

Thanks

evanshortiss commented 7 years ago

@Satyam could you maybe provide a little more detail. What is the mp3 tag reader? I'm surprised to hear it expects a node.js fs instance, unless it was designed to use this module which is a copy of the node.js API?

Satyam commented 7 years ago

I am still trying out some tag readers, but the only one remaining so far that uses fs directly is mp3-duration at https://github.com/ddsol/mp3-duration/blob/master/index.js which, anyway, uses raw fs.open and fs.read so it wouldn't work anyway. The others either take a Buffer or a ReadableStream both of which I can produce.

Anyway, I was not able to reach the music files themselves, just to list them with fs.readdir. They are sometimes located in the external sd-card, not in the main drive which is where filesystem.root seems to point to. External memory cards provide much more storage and both pictures and music files are often off-loaded there. Also, how to read a text file send with the package, usually located along other assets in the package, such as initial configuration file, license agreement, sql database file initialization?

These are separate questions, and I' appreciate if you can give me a hint on that. In the meantime I'm closing this issue since the question is no longer relevant.

Thanks

evanshortiss commented 7 years ago

@Satyam mp3-duration looks like a native node.js module, but if you're using browserify perhaps it'll work. Things like Buffer typically are not found in JavaScript in web browsers, but perhaps a shim is available.

This html-fs might need updates to resemble the core node.js module more accurately.

how to read a text file send with the package, usually located along other assets in the package, such as initial configuration file, license agreement, sql database file initialization I'm not sure I understand this question. Do you mean how can you read these from the app itself, e.g config.xml? I'm not sure if that is possible since I've never tried, I've only read/written text/json files, but perhaps the applicationDirectory can be read for these as detailed here