Sencha触摸2媒体存储

时间:2014-05-08 06:38:22

标签: sencha-touch-2 local-storage

我正在使用适用于Android和iOS的Sencha Touch 2应用程序。应用程序将在登录时加载图像和视频,我需要将它们缓存在应用程序中。我知道视频缓存将是巨大的负载,但请让我知道,我们可以将图像文件存储在应用程序本地文件夹或其他一些实现。

提前完成。

1 个答案:

答案 0 :(得分:0)

我是SIMpalm(http://www.simpalm.com)的开发人员,是的,您可以在设备中存储文件,您应该使用phonegap(http://docs.phonegap.com/en/3.0.0/cordova_file_file.md.html#File)文件系统进行下载。

它将在默认位置下载文件。

您应该在目标位置移动文件。

示例:

function getImageURI(imageURI){

var gotFileEntry = function(fileEntry) {
    //  alert("got image file entry: " + fileEntry.fullPath);
    var gotFileSystem = function(fileSystem) {


        fileSystem.root.getDirectory("TestFolder", {
            create : true
        }, function(dataDir) {
            var FileNewName = "test.jpg" ; //you can rename the file
            // Move the file
            fileEntry.moveTo(dataDir, FileNewName, success1, fsFail);

        }, dirFail);

    };
    // get file system to copy or move image file to
    window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFileSystem,
    fsFail);
};
// resolve file system for image
window.resolveLocalFileSystemURI(imageURI, gotFileEntry, fsFail);

var success1= function(success){
    //Moving Success
    var newFilePath=success.fullPath;

//Here you can save new path of your downloaded file

};
// file system fail
var fsFail = function(error) {
    console.log("failed with error code: " + error.code);

};

var dirFail = function(error) {
    console.log("Directory error code: " + error.code);

};

} //结束getImageURI