Phonegap 3.4 - getFile fails - file

Upgraded my app to phonegap 3.4 and reading a text file (db.txt) in the root of the www folder now fails.
The following snippet used to work:
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, this.gotFS, this.fail);
this.gotFS = function(fileSystem) {
console.log(fileSystem.name);
fileSystem.root.getFile("../MyappName.app/www/db.txt", {create: false, exclusive: true}, file_reader.gotFileEntry, file_reader.fail);
};
I've read here some changes occured in the file api but even if I use
fileSystem.root.getFile("db.txt", {create: false, exclusive: true}, file_reader.gotFileEntry, file_reader.fail);
};
or
fileSystem.root.getFile(fileSystem.root.toURL()+"db.txt", {create: false, exclusive: true}, file_reader.gotFileEntry, file_reader.fail);
};
file_reader.fail is always called with the error code of 5 which is ENCODING_ERR.
So basically how do you read a file in the root of the www folder with the new file api?

Related

Upload a file using React and Express

i want to upload a zip file from a client to my server. On my client side i have adapt the code from this site. In my express server i notice that my request is
req.files: { file:
{ fieldName: 'file',
originalFilename: 'myZIP.zip',
path: '/tmp/myPath',
headers:
{ .....},
size: 11757,
name: 'myZIP.zip',
type: 'application/zip' } }
Is there any way to upload my file without give the path of the file /tmp/... ? Or this is the only way that uploads works in general?

After setup RUM application of datadog page load blank on server in react

RUM application intilize code.
Added this code in main.js file. But after deployed my build on non-ssl site i getting a blank page. Nothing any console error displaying and network tab also clear
import { datadogRum } from '#datadog/browser-rum';
const env = window.location.hostname;
datadogRum.init({
applicationId: 'xyz',
clientToken: 'xyz',
site: 'datadoghq.com',
service: 'foundation---vdeck',
version: '5.35.2',
sampleRate: 100,
env,
premiumSampleRate: 100,
trackInteractions: true,
defaultPrivacyLevel: 'mask-user-input',
useCrossSiteSessionCookie: true,
trackSessionAcrossSubdomains: true,
silentMultipleInit: true,
});
datadogRum.startSessionReplayRecording();

CSSNext postcss-custom-media - unable to import medias from file with 'importFrom' option

I'm trying to add customMedia option to my postcss-cssnext features config with importFrom file location, but that doesnt work and I dont have any errors on project build, only final Missing #custom-media definition for '--small-viewport'. The entire rule has been removed from the output. when I'm trying to use the media. How do I debug this?
module.exports = {
plugins: [
require('postcss-import')(),
require('postcss-nested')(),
require('postcss-simple-vars')({
variables: {
...require('./src/ui/variables')
}
}),
require('postcss-cssnext')({
features: {
customProperties: false,
browsers: ['> 0.5%, last 2 versions, Firefox ESR, not dead'],
customMedia: {
importFrom: require('path').join(__dirname, './src/ui/custom-media.css')
}
},
}),
require('cssnano')({
autoprefixer: false,
zindex: false,
reduceIdents: false,
discardComments: { removeAll: true },
discardUnused: { fontFace: false },
colormin: false,
}),
]
};
Okay so as per postcss-custom-media CHANGELOG importFrom was added only in 7.0.0 while my cssnext uses 6.0.0. As CSSNext is deprecated I will switch to postcss-preset-env
you know how to use custom media in postcss-preset-env, they work for me only if you create a custom media in the component and refer to it if I want to take custom media from index.css or vars.css they do not work , with variables everything is fine

angular-csv-import not working on ionic

I am trying to use angular-csv-import on ionic. all works greate on chrome but when I am trying to run it on android nothing is happens...file manager to upload the file isnt working....what can be done?
my code is:
template:
<ng-csv-import content="csv.content"
header="csv.header"
separator="csv.separator"
result="csv.result"
accept="csv.accept">
</ng-csv-import>
controller:
$scope.csv = {
content: null,
header: true,
headerVisible: true,
separator: ',',
separatorVisible: true,
result: null,
encoding: 'ISO-8859-1',
encodingVisible: true,
accept: ".csv"
};
I find 2 ways to do it.
One way to save the document from google shits and get plugin to parse it to json, then use ng to download parsed json. Or the other way to use xlsx parser

i18next is not loading the translation file

I am working on some Backbone based project where i am using i18next for locales.
Following is my app.js code:
/*
This file is used to initialize your application.
*/
require(['i18n','application','handlebars_Helpers'], function(i18n, Application) {
i18n.init({
lng: 'en',
debug: true,
fallbackLng: false,
load:'unspecific',
resGetPath: "locales/__lng__/__ns__.json",
ns: {
namespaces: ['translation']
}
});
(new Application()).initialize();
});
Translation file:
{
"loginModule": {
"signin": "Sign In"
}
}
Following is my helper file:
/**
* Set of generic handlebars helpers
*/
define(['i18n'], function(i18n) {
/**
* This helper provides i18Next in templates
*
*
* Usage: span {{t "my.key" }}
*/
Handlebars.registerHelper('t', function(i18n_key) {
var result = i18n.t(i18n_key);
return new Handlebars.SafeString(result);
});
return Handlebars;
});
When i am loading my page through localhost it shows me following message in console:
currentLng set to: en i18n.js:490
GET http://localhost:8000/locales/en/translation.json?_=1374495189376 404 (Not Found) i18n.js:376
failed loading: locales/en/translation.json
Don't understand what i am missing? or why this error is show?
In which folder do you store translations file? Default behavior for i18n is, that it tries to find localization file in specific path: /locales/{lang-code}/{namespace}.json
If you keep file in root, try to change initialization code to following:
i18n.init({
lang: 'en',
debug: true,
fallbackLng: false,
load:'unspecific',
resGetPath: "__ns__-__lng__.json",
ns: {
namespaces: ['translation'],
defaultNs: 'translation'
}
});
This will try to load file from following url: http://localhost:8000/translation-en.json
Basically, try to check location of translations file, name of translation file and construct 'regGenPath' accordingly, more info can be found in i18n documentation http://i18next.com/node/pages/doc_init.html

Resources