Since i cant play an audio file from a DB blob, i have to write it as a file, before i can play it.
Looking at the documentation, my choices are:
Ti.Filesystem.applicationDataDirectory
Ti.Filesystem.tempDirectory
Ti.Filesystem.externalStorageDirectory
Ti.Filesystem.applicationCacheDirectory
Considering that i want my file to be secret, so no other app can see that file, what is my best option?
EDIT: So the issue is more with Android, i'm afraid that any file browser will be able to find the file.
I'm assuming you're building for android, because ios data are sandboxed and not readily accessible by default (until ios8). Rather than hiding them, just encode them using base64encode(). And then you can decode when accessing the file with base64decode().
With that said, I've never had to use it. So, I don't have an example. But you can read about it in the api doc.
Hope that helps.
You haven't mentioned if you are building an app for iOS or Android. For example Ti.Filesystem.externalStorageDirectory is available only for Android (SD card).
Anyway if you want to save an audio file, you should save it in <Application_Home>/Documents ,so you should use Ti.Filesystem.applicationDataDirectory. Don't forgot to set up a remoteBackup flag see http://docs.appcelerator.com/titanium/3.0/#!/api/Titanium.Filesystem.File-property-remoteBackup
Also have a look at iOS Data Storage Guidelines for more details
https://developer.apple.com/icloud/documentation/data-storage/index.html
*If you want to save an audio file only because you need to play it ,but you don't need to store it in a fileSystem then is better to use Ti.Filesystem.tempDirectory
Related
Is there a reliable way to create a file (specifically via Print.printToFileAsync API), and since it creates the new file in the user's cacheDirectory, copy it across to their documentDirectory - that works in both Android and iOS?
I've come across others trying to do the same thing here, but to no avail.
One solution I've seen is to use the MediaLibrary API to download the file to the device's CameraRoll - but this is hacky and doesn't work on iPhone since the file I'm trying to copy/download is a PDF, and not an image/movie.
Various solutions are listed here too - but they either don't work, or only work in one OS.
My end goal is to be able to generate a PDF on the device and save it to the user's storage, without needing to send information back to the server.
My app is not ejected as it stands.
Any advice/direction would be appreciated!
EDIT 1:
Considering ejecting at some stage, but due to the nature of the project I'm working on I'd prefer to do that right at the end. Also came across this post which tries to Share the file URI, but this isn't supported on Android.
I hope you dont have any problem with creating the pdf,to save the file have you tried
https://github.com/Lyrillind/react-native-file-manager
it supports both anroid and ios.
If you want you can build your own native module to save the file ,
http://facebook.github.io/react-native/docs/native-modules-ios.html#content
I am making a mobile app using Cordova and I need to save some sensitive and not so sensitive data inside the phone. I am a bit lost on what is the best way to do it.
I need to save:
A JSON web-token (for authentication).
A response from server (I save this to populate my page in case the GET request fails).
Coordinates information when user is logging data to the app (for later upload to a server from with in the app). These will be many separate logs, and can be large in size for local storage ~5-10 MB.
Till now i have been successfully saving everything I need to the local storage but I don't think that is the correct way to do it. So that is why I need some help in deciding what is the best course to take from security point of view.
Saving server response is just for better UI experience and static in size so I guess local storage is a good option to use.
But web-tokens and GPS logs is sensitive information and I dont want to keep it in the local storage as it is accessible from outside the app.
What other options do I have?
Cordova still doesn't have encrypted storage.
Is saving to files a good approach? This here says that data contained inside cordova.file.applicationStorageDirectory is private to the app.So can I use it to save the logs and the token?
The plugin also lists the file systems for Android and iOS and lists which of those are private.
I am currently working with android phones but want to extend the app to iOS later. I have never worked with file systems and caches before so I am a bit lost.
I have an app that uses chat stickers. I would like to add more stickers to the app over time without having to make the user download an update. I understand that I can store data in NSUserDefaults so was wondering if it's possible to get an app to download images from a server to the NSDefaults? Say via parse or a similar service? Is this kind of thing allowed in an app? I read something in the developer guidelines that placeholders could not be used. Any advice on this would be really appreciated. Thanks!
If you want to use parse the store all the images in a table in the parse file storage. Download the images using the Parse SDK. The downloaded images will be cached appropriately by the SDK so you won't need to handle the cache yourself.
You can read more about how to store files with Parse here: https://www.parse.com/docs/ios_guide#files/iOS
NSUserdefaults is not meant to store big files like images. It should only contain small amounts of data.
You will need to download the images and save them locally. To download the image to a file use NSURLDownload.
My iPad app currently saves user input data in a TSV (tab separated values) file. At the end, the user emails this file out. The problem now is that I have to abide by certain policies because the information is sensitive. Is there a way to encrypt the TSV file before it is emailed?
Note: I've decided to EMAIL this TSV file because I have found NO other way to get this file onto a computer from the iPad's sandbox. If there is a better way than email, I will gladly implement it (EXCEPT using iTunes to download the app's sandbox data, which does NOT abide by the policies).
THANKS AHEAD OF TIME!
Use iFunBox. You can copy files directly from an iOS device. No jailbreak required.
To encrypt your file, you can use any encryption algorythm for text, like AES
Then, to send the data to your server, you can post it using a web service. ASIHTTPRequest can help for this.
Good luck with that!
I want to develop small mac (not iphone) application for self-educational purpose.
What application should do: just open video file and show information about video codec.
Main problem is that i never work with media files and i don`t now from which point i can start.
May be somebody can advice some articles or may be even examples?
I strongly recommend using something like FFmpeg to get codec information.
Simply run the following command through NSTask:
ffmpeg -i video.mpg
Project page:
http://www.ffmpeg.org/
Extracting this information yourself is a LOT of work.
Every video format stores things different.
Not to mention error-handling and corrupted files.
The codec data is usually held in container formats. To start you should pick one container format and parse that, a popular one would be the MPEG4 container format. Follow the links from this page to get you started.
http://en.wikipedia.org/wiki/MPEG-4_Part_14