Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const uploadNdkCrashesIfAny = async () => {
// This file path should be same here and in MainApplication.java
const ndkCrashLogsFilePath = RNFS.CachesDirectoryPath + '/ndk_crash_logs.txt'
const ndkCrashLogcatLogsFilePath = RNFS.CachesDirectoryPath + '/ndk_crash_logcat_logs.txt'
if (!(await RNFS.exists(ndkCrashLogsFilePath))) {
Logger.debug(
'Sentry@uploadNdkCrashesIfAny',
`crash log file ${ndkCrashLogsFilePath} not found, no native crashes recorded`
)
return
}
const fileSize = parseInt((await RNFS.stat(ndkCrashLogsFilePath)).size, 10)
Logger.info(
'Sentry@uploadNdkCrashesIfAny',
`crash log file ${ndkCrashLogsFilePath} found (${fileSize} bytes), capturing it via Sentry`
)
const msg1 = (await RNFS.exists(ndkCrashLogcatLogsFilePath))
? await RNFS.readFile(ndkCrashLogcatLogsFilePath)
const uploadNdkCrashesIfAny = async () => {
// This file path should be same here and in MainApplication.java
const ndkCrashLogsFilePath = RNFS.CachesDirectoryPath + '/ndk_crash_logs.txt'
const ndkCrashLogcatLogsFilePath = RNFS.CachesDirectoryPath + '/ndk_crash_logcat_logs.txt'
if (!(await RNFS.exists(ndkCrashLogsFilePath))) {
Logger.debug(
'Sentry@uploadNdkCrashesIfAny',
`crash log file ${ndkCrashLogsFilePath} not found, no native crashes recorded`
)
return
}
const fileSize = parseInt((await RNFS.stat(ndkCrashLogsFilePath)).size, 10)
Logger.info(
'Sentry@uploadNdkCrashesIfAny',
`crash log file ${ndkCrashLogsFilePath} found (${fileSize} bytes), capturing it via Sentry`
)
const msg1 = (await RNFS.exists(ndkCrashLogcatLogsFilePath))
async function androidResourcePath(resourceName) {
var destinationPath = RNFS.CachesDirectoryPath + '/' + resourceName;
await RNFS.copyFileAssets(resourceName, destinationPath).catch((err) => {
console.log('Failed to copy android resource: ' + resourceName + ', err message: ' + err.message + ', err code: ' + err.code);
return undefined;
});
return destinationPath;
}
onConvert() {
var localInputFileName = "";
var randomFileName = RNFS.CachesDirectoryPath + "/" + Math.random().toString(36).substring(5) + ".gif";
var resolvedFile = localInputFileName = "http://techslides.com/demos/sample-videos/small.mp4";
this.setState({
fileName: randomFileName,
imageAvailable: false,
progress: 0.001
});
console.log("resolved file " + resolvedFile);
console.log("writing output file " + randomFileName);
var remoteFileName = this.getRemoteFileName(resolvedFile);
const progress = p => {
var prog = p.progress/100
this.setState({
progress: prog
});
var randomFileName = RNFS.CachesDirectoryPath + "/" + Math.random().toString(36).substring(5) + ".gif";
var resolvedFile = localInputFileName = "http://techslides.com/demos/sample-videos/small.mp4";
this.setState({
fileName: randomFileName,
imageAvailable: false
});
console.log("resolved file " + resolvedFile);
console.log("writing output file " + randomFileName);
var remoteFileName = this.getRemoteFileName(resolvedFile);
const progress = p => {
console.log("javascript completed percent - " + p.progress);
}
if (resolvedFile.search(/http/i) >= 0) {
var localInputFileName = RNFS.CachesDirectoryPath + "/" + remoteFileName;
console.log("remote file is being used - probably running under debugger. Will download the file now");
console.log("Downloading to file " + localInputFileName);
RNFS.downloadFile({
fromUrl: resolvedFile,
toFile: localInputFileName
}).promise.then(res => {
console.log("Downloaded file file://" + localInputFileName);
this.setState({
imageAvailable: false
});
ReactNativeFFMpeg.encodeVideoOnly(
{
fromFile: localInputFileName,
toFile: randomFileName,
progress
}
const params = uri.split('?');
if (params.length < 1) {
throw new Error('Unknown URI:' + uri);
}
const keyValues = params[1].split('&');
if (keyValues.length < 2) {
throw new Error('Unknown URI:' + uri);
}
const kvMaps = keyValues.reduce((prv, cur) => {
const kv = cur.split('=');
prv[kv[0]] = kv[1];
return prv;
}, {});
const itemId = kvMaps.id;
const ext = kvMaps.ext.toLowerCase();
const destPath = RNFS.CachesDirectoryPath + '/' + itemId + '.' + ext;
let promise;
if (item.type === 'ALAssetTypePhoto') {
promise = RNFS.copyAssetsFileIOS(uri, destPath, 0, 0);
} else if (item.type === 'ALAssetTypeVideo') {
promise = RNFS.copyAssetsVideoIOS(uri, destPath);
} else {
throw new Error('Unknown URI:' + uri);
}
return promise
.then((resultUri) => {
data[index].uri = resultUri;
});
});
Promise.all(promises)
input.captureFrame({type:'png', format:'file', filePath: path, quality:1}).then((filePath) => {
LOG('captured!', RNFS.CachesDirectoryPath, filePath, arguments)
this.state.imagePath = filePath
this.setState(this.state)
});
getGethLogFilePath = () => {
return RNFS.CachesDirectoryPath + '/geth_logs.txt'
}