local-files

How to fetch data from local JSON file on react native?

自闭症网瘾萝莉.ら 提交于 2019-11-26 19:06:58
问题 How can I store local files such as JSON and then fetch the data from controller? 回答1: Since React Native 0.4.3 you can read your local JSON file like this: const customData = require('./customData.json'); and then access customData like a normal JS object. 回答2: ES6/ES2015 version: import customData from './customData.json'; 回答3: For ES6/ES2015 you can import directly like: // example.json { "name": "testing" } // ES6/ES2015 // app.js import * as data from './example.json'; const word = data

Play audio local file with html

笑着哭i 提交于 2019-11-26 11:30:54
问题 I\'m trying to do something like this. But I don\'t know why I\'m not getting this thing work. Here it is the codepen example: $(\'input\').on(\'change\', function(e) { var file = e.currentTarget.files[0]; var reader = new FileReader(); reader.onload = function(e) { $(\'audio source\').attr(\'src\', e.target.result); } reader.readAsDataURL(file); }); The source tag is receiving the base64 mp3 file, but it doesn\'t load the file into browser. 回答1: You set the src attr directly on the audio

Allow Google Chrome to use XMLHttpRequest to load a URL from a local file

元气小坏坏 提交于 2019-11-26 00:07:33
问题 When trying to do a HTTP request using XMLHttpRequest from a local file, it basically fails due to Access-Control-Allow-Origin violation. However, I\'m using the local web page myself, so I was wondering if there is any way to make Google Chrome allow these requests, which are from a local file to a URL on the Internet. E.g., $.get(\'http://www.google.com/\') fails when executing in a local file, but I\'ve scripted the page myself and I\'m using it myself, so it would be extremely useful if I

Loading local JSON file

我只是一个虾纸丫 提交于 2019-11-25 23:59:19
问题 I\'m trying to load a local JSON file but it won\'t work. Here is my JavaScript code (using jQuery: var json = $.getJSON(\"test.json\"); var data = eval(\"(\" +json.responseText + \")\"); document.write(data[\"a\"]); The test.json file: {\"a\" : \"b\", \"c\" : \"d\"} Nothing is displayed and Firebug tells me that data is undefined. In Firebug I can see json.responseText and it is good and valid, but it\'s strange when I copy the line: var data = eval(\"(\" +json.responseText + \")\"); in

How can I create a link to a local file on a locally-run web page?

淺唱寂寞╮ 提交于 2019-11-25 22:35:59
问题 I\'d like to have an html file that organizes certain files scattered throughout my hard drive. For example, I have two files that I would link to: C:\\Programs\\sort.mw C:\\Videos\\lecture.mp4 The problem is that I\'d like the links to function as a shortcut to the file. I\'ve tried the following: <a href=\"C:\\Programs\\sort.mw\">Link 1</a> <a href=\"C:\\Videos\\lecture.mp4\">Link 2</a> ... but the first link does nothing and the second link opens the file in Chrome, not VLC. My questions