Use local files and qrc - javascript

I have all my QML files provided by QRC. I want one js file to be a local file. I create a data.js file
.pragma library
var data = "some data"
The call
import "data.js" as Data
fails, since QML looks for the file in qrc:/ and the file is stored locally.
Can I use the local file from QML without dropping QRC for the rest of the files?

Related

React Native: How to play local .midi files?

I have a React Native application in which I am trying to play different sounds with different extesions like .mp3, .wav, .midi. My issue is that I can't access the midi file that is stored locally in assets folder.
I tried by importing directly like
import midiFile from './assets/1.midi';
or through a index.js file in assets folder:
import midiFile from './1.mid';
const Assets = {
midiFile,
};
export default Assets;
And also tried to open with react-native-fs like const midiFile = await RNFS.readFile('../assets/1.midi'); but with every method I will get that the 1.midi file does not exist and I double, triple check everytime that the path is correct (created a totally new project with just App.tsx and assets folder)
How can I use my local .midi file? Is there any change needed in metro.config.js or other file?
My scope is to play the sound through the react-native-sound which works with .mp3 files but I also need to make it work with .midi files.
Thank you

How to read files from resource folder of spring boot application using javascipt

I have some files under resources/test/feature/a.feature , b.feature like that , i want read those files using javascript , and the jacascript file location is resources/test/js/read.js. I am using below code to read
function processFeatures() {
var features = [];
var featuresResources = $resources("feature/.*?\\.feature");
for(var i in featureResources) {
var feature = JSON.parse($eval(featureResources[i].content))
features.push(feature);
}
return features;
}
This code works when i run the application from intellij, but when i build a jar file and then run the jar file separately that time it fails to read. I printed the featuresResources , that time it giving empty response.
What needs to do in that case.
i will suggest you to use java code instead of java script or call code from java script to read file
But in your case,
its all because of jar file doesn't contain file structure in same manner as you see in your IDE verify your file path in built folder which have final structure which server will run.

How to import a js file in Angular Library?

I am creating a Angular Library which will be using a js file for operations. How do I import this file in Library since it doesn't contain angular.json file.
In Normal app which could just add it to scripts in angular json and access through global variable but not sure about this.

VueJS reference a local JSON file outside of build

I have some JSON data that I'm working with in a Vue project. In development I'm referencing and using the JSON data as shown below
<script>
import Versions from './../JSONVersionData/versions.json'
export default {
data: function () {
return {
Versions
}
},
}
</script>
My webpack configuration compiles all my Javascript to an app.js file in dist. This means that the JSON files are compiles into this app.js file.
My aim is to allow the versions.json file to manually edited in the dist file so it can be maintained without needing the end user to recompile the JS assets.
Is this possible? Can I make my Javascript look for a local copy of the JSON data file rather than a bundled version of the file?

Is it possible to pick the CSV file automatically from the file directory using Papa parse?

I have the following directory structure for my application:
css
files
js
images
index.html
my csv file is located in the folder "files". I want my js to pick the csv file automatically from the directory and pass that file to Papa parse.
I need to implement this because this is the requirement. I am not allowed to pick the file using input tag of html.
Please let me know if it is possible, then how can implement this.
If not possible then please let me know the another way to do this.
If this is on your local machine, you must set up a simple server which will allow your JS file to read it. This can be done as described below:
Navigate to the folder that contains your CSV files
Within that folder, run the command $ python3 -m http.server
This will allow the files to be available over the link http://lvh.me:8000/your_csv_file.csv
Next, in your JS file using Papa Parse, paste the following:
Papa.parse("http://lvh.me:8000/your_csv_file.csv", {
//parameters to set
download: true,
header: true,
complete: function(results) {
console.log(results);
}
});
On Chrome, you must enable cross-origin resource sharing. You could use the app Allow-Control-Allow-Origin
Using Chrome, navigate to your webpage and look at the console log. The content of your CSV file will be there!

Categories