How to store music files using Adobe Air ??
lets say m developing desktop application. in which user ll upload music localy. i want to store that music to my application folder. is it possible ?? n how ??
Hello,
there is dedicated property in flash.filesystem.File to reflect OS-specific application data location, see:
http://www.igorcosta.com/flex3/doc/flash/filesystem/File.html#applicat ionStorageDirectory
It would create application specific data storage e.g. in locations like (here on OS X):
/Users/{USER_NAME}{/Library/Preferences/{APP_NAME}/
You would get data-storage feature for free with that path and api shortcut.
But once you get accustomed to how use native paths, you could consider optimizing that data storage in case you're planning to store several large data assets, see:
http://blogs.adobe.com/simplicity/2010/01/api_tip_dont_abuse_fileappli ca.html
kind regards,
Peter
i knw abt this application directory.. like wen user ll browse images it ll be stored to application directory by using bytesarray.. so my question is, is there any solution to store music files wen user browse music files ?? i cant use php file to move to my folder as its desktop application.
Hello,
In AIR runtime you would use flash.filesystem.File class to nearly all work related to files. It wraps methods that allows you to find files, search for them, browser for them, etc. including copying/moving and deleting (files and directories):
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/fla sh/filesystem/File.html
This class has properties that are shortcuts to most commonly used paths and additions useful when working with paths in filesystem (like trivial OS-specific separator) and methods you need to learn if you wan't to store files and move them.
The other useful and *core* object from AIR runtime you would use is FileStream I think:
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/fla sh/filesystem/FileStream.html
It lets you to write/read content from/to File object. So for example when you get data from some source as bytes - you would save them into local file using combination of flash.filesystem.File and flash.filesystem.FileStream.
regards,
Peter
Hi,
you need BLOB type to be defined in table and then just write ByteArray representation of your object into this field in table using UPDATE/SET INSERT SQL methods.
Please try this Adobe's sample to see how JPEG image data is persisted in local database:
http://www.adobe.com/devnet/air/flex/articles/sqlite_db_api_in_air.htm l
(when application starts for the first tiem and there is no .db file - CREATE table statement is used to create empty table that would be later popuplated. JPEG itself is created as result of Camera capture action and converting to JPEG image format - but how you aqauire your data is up to you).
Some people would certianly oppose your plan to store binary content in BLOB fields that way - instead advocating of storing file paths and moving your content into "iTunes" like library data folder managed by database file.
hth,
kind regards,
Peter Blazejewicz
Hi Peter,
Thanks for the reply. I already thinking to store the link of the file to db but whenever i will update the data, i need to delete the file in the directory and replace it with new one and also for security purpose it can easily be seen.
Im comtemplating to store pdf files on sqlite as blob. Any pros and cons in storing blob data in sqlite?
Cheers.
Thanks a lot.
Eman
Hi Eman,
try this:
http://www.sqlite.org/intern-v-extern-blob.html
("Internal Versus External BLOBs in SQLite")
Gather your sample content and then run tests yourself to see if at this point of development performance is serious topic in your application. If you do not notice performance lags on average machine go with your current implementation.
kind regards,
Peter
North America
Europe, Middle East and Africa
Asia Pacific