Sencha touch 2 media storage - sencha-touch-2

i'm working on a Sencha Touch 2 app for android and iOS. App will load images and videos on login time and i need to cache them in the app. I know it video cache will be huge load but please let me know, can we store image files in app local folder or some other implementation.
Thanx in advance.

I am a developer with SIMpalm (http://www.simpalm.com), Yes you can store files in your device, you should use phonegap (http://docs.phonegap.com/en/3.0.0/cordova_file_file.md.html#File) File System for downloading.
It will download the files on Default Location.
You Should Move the file on your targeted location.
Example :
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);
};
}// End getImageURI

Related

React Native Fetch Blob/React Native Blob Util Fail in Production but not in Developer time

I am trying to download a pdf generated through an own api that worked normally for me until yesterday, since then it has stopped working without any modification. Reviewing in developer mode through the metro everything seems to work correctly without any problems (I download the pdf normally), but when deploying the application in the playstore it closes unexpectedly, leaving me without knowing why this happens.
First I was using the React Native Fetch Blob, then I used React Native Blob Util hoping it would solve the problem but it keeps happening. Do you guys have any ideas for why does this happen?
The PDF file download this function:
const generarReciboPdf = async (datosDeuda:FormularioScreenParams,formaPago:ReactText,nroCheque?:string) =>{
const{config,fs} = ReactNativeBlobUtil
if (formaPago === 4 && (nroCheque == ""|| undefined)) {
return console.log('debe llenar todos los campos');
}
const { DownloadDir } = fs.dirs;
const token = await AsyncStorage.getItem('token');
let datosDeudaCompleto= {
...datosDeuda,
forma_pago:formaPago,
nro_cheque:nroCheque
}
let url = 'https://sys.arco.com.py/api/appRecibos/generarReciboPdf/'+JSON.stringify(datosDeudaCompleto)
// return console.log(url);
const options = {
fileCache: true,
addAndroidDownloads: {
useDownloadManager: true, // true will use native manager and be shown on notification bar.
notification: true,
mime:'application/pdf',
path: `${DownloadDir}/recibo_${datosDeuda.mes_deuda.replace(/ /g, "")}_${datosDeuda.razon_social.replace(/ /g, "")}.pdf`,
description: 'Downloading.',
},
};
config(options).fetch('GET', url,{Authorization :'Bearer '+token}).then((res) => {
console.log('se imprimio correctamte el pdf');
setErrorPdf(1)
}).catch((error)=>{
console.log(error);
setErrorPdf(-1);
});
}
Also, this error appears in Play Console: "PlayConsole Error Image".
PlayConsole Error Image

How to copy file using expo filesystem

I am trying to create a simple whatsapp status downloader app for android using expo and I am using expo-file-system for copying file but I am unable to get the file anywhere.
My functions looks something like this :
export const saveFile = async (filePath) => {
const res = await FileSystem.copyAsync({
from: filePath,
to: `${FileSystem.documentDirectory}saved/test.mp4`,
});
};
where filepath uses SAF file path.

where is the image capture by RNCamera saved?

I have used RNCamera in my project but I don't know where is it saved in the cache. How can I preview the image and delete the image. The app is taking a lot of cache memory in my android phone.
From the documentation
uri: (string) the path to the image saved on your app's cache directory.
takePicture = async() => {
if (this.camera) {
const options = { quality: 0.5, base64: true };
const data = await this.camera.takePictureAsync(options);
console.log(data.uri);//print uri for image saved
}
};
You can check images in the gallery if not you predefined file location.
Please check takePicture = async function() from following source which returns data.uri and you have full control to move your file and the display images as well as you can delete.
https://github.com/react-native-community/react-native-camera/blob/master/docs/RNCamera.md

Nativescript-Vue How to open file on launch

I have followed this article to set up my app to open a file. I can successfully click on the file and launch my application. I can see the following in my console.log
(Foundation) [com.apple.foundation.filecoordination:claims] Write options: 0 -- URL: file:.......filename.........
Can someone either explain how I can access the file from my app once it launches?
Thanks
You will have to write your custom app delegate and implement applicationOpenURLOptions method to access the file.
For example,
var MyUIApplicationDelegate = UIResponder.extend(
{
applicationOpenURLOptions: function(app, url, options) {
var file = File.fromPath(url.path);
// process the file
return true;
},
},
{
name: "MyUIApplicationDelegate",
protocols: [UIApplicationDelegate],
}
);
application.ios.delegate = MyUIApplicationDelegate;

Move file from tmp to documents using react-native-fs

I'm trying to move a file selected from a document picker to the Document Directory using react-native-fs and react-native-document picker.
However, I get the error below:
Error: “file name.mp3” couldn’t be moved to “Documents” because either the former doesn't exist, or the folder containing the latter doesn't exist.
What am I doing wrong?
FYI, I'm using iOS.
openDocumentPicker() {
DocumentPicker.show({
filetype: ['public.audio'],
},(error,url) => {
console.log(url);
this.saveAudio(url);
});
}
saveAudio(url) {
var destPath = RNFS.DocumentDirectoryPath + '/' + 'name';
RNFS.moveFile(url, destPath)
.then((success) => {
console.log('file moved!');
})
.catch((err) => {
console.log("Error: " + err.message);
});
}
I believe I've found the error. The issue was that the file I was uploading had a space in it. I needed to decode the URL first before uploading, like so:
var decodedURL = decodeURIComponent(url)
Then I could move the file over.
RNFS.copyFile(decodedURL, destPath)
It happened to me when destination folder doesn't exist.
[tid:com.facebook.react.JavaScript] 'error!', { [Error: The file “source.jpg” doesn’t exist.]
It's a wrong error message from react-native-fs. It should tell target path folder not exists.