filereader

Get base64 of audio data from Cordova Capture

痴心易碎 提交于 2019-11-29 07:42:42
I am using ngCordova Capture to write this code by recording audio and send the base64 somewhere (via REST). I could get the Capture Audio to work but once it returns the audioURI, I cannot get the data from the filesystem as base64. My code is below: $cordovaCapture.captureAudio(options).then(function(audioURI) { $scope.post.tracId = $scope.tracId; $scope.post.type = 'audio'; console.log('audioURI:'); console.log(audioURI); var path = audioURI[0].localURL; console.log('path:'); console.log(path); window.resolveLocalFileSystemURL(path, function(fileObj) { var reader = new FileReader(); console

Getting Data from FileReader in Angular 2

℡╲_俬逩灬. 提交于 2019-11-29 07:41:50
I am trying to create an upload form in Angular 2 ts (2.2.1), that allows the upload of e.g. a CSV file, but instead of the file being sent straight to a http service I want the file first to be validated in the browser. So far I can already upload a file and print it in the console with this code: Html input for file upload <input type="file" (change)="changeListener($event)" #input /> In my angular component I have set up the eventListner and the File reader. export class UploadComponent { public fileString; constructor() { this.fileString; } changeListener($event): void { this.readThis(

java.lang.ClassCastException: org.json.simple.JSONArray cannot be cast to org.json.JSONArray

跟風遠走 提交于 2019-11-29 07:34:23
I need to read a JsonArray data from a file (on an SD card) and store it into a SQLite database. but I am getting a java.lang.ClassCastException: org.json.simple.JSONArray cannot be cast to org.json.JSONArray exception while parsing data to JsonArray . Data in the file is very huge, the whole data can not be stored in a single String or String Buffer or String Builder. Here is my code. FileReader fileReader = new FileReader(file_path); Object obj = jsonParser.parse(fileReader); JSONArray jsonArray = (JSONArray) obj; // Exception. Please help.. Check your import statements at the top of your

Are there file size limitations when using javascript FileReader API?

此生再无相见时 提交于 2019-11-29 06:45:24
You can use javascript FileReader API to display a preview of an image which is provided from a file input field. This comes in very useful in the sense that you don't have to use server side php and ajax to display the image. My question though is this: Is there any limit to the size of the image file being used? Like if a user was to select an image that is 20MB, would the filereader be able to handle it? And would the machines memory potentially become max-ed out? I'm testing just locally on my machine at the moment. I attempted to load a bmp file (53MB!), which took about 15 seconds to

io流--Properties

天大地大妈咪最大 提交于 2019-11-29 06:18:22
Properties 是唯一一个与IO流相交互的集合Properties 类表示了一个持久的属性集。 Properties 可保存在流中或从流中加载。属性列表中每个键及其对应值都是一个字符串。 特点:定死了键值对是String类型的 1、Hashtable的子类,map集合中的方法都可以用。 2、该集合没有泛型。键值都是字符串。 3、它是一个可以持久化的属性集。键值可以存储到集合中,也可以存储到持久化的设备(硬盘、U盘、光盘)上。键值的来源也可以是持久化的设备。 4、有和流技术相结合的方法。 load(InputStream) 把指定流所对应的文件中的数据,读取出来,保存到Propertie集合中 load(Reader) store(OutputStream,commonts)把集合中的数据,保存到指定的流所对应的文件中,参数commonts代表对描述信息 stroe(Writer,comments); package com.oracle.demo01; import java.util.Properties; public class Demo01 { public static void main(String[] args) { //创建Properties集合 Properties pro=new Properties(); //向集合中存键值对 pro.put(

io流--转换流,缓冲流

主宰稳场 提交于 2019-11-29 06:17:58
功能: 转换吗?转换流。InputStreamReader OutputStreamWriter 高效吗?缓冲区对象。BufferedXXX unicode:国际标准码表:无论是什么文字,都用两个字节存储。 l Java中的char类型用的就是这个码表。char c = 'a';占两个字节。 l Java中的字符串是按照系统默认码表来解析的。简体中文版 字符串默认的码表是GBK。 UTF-8:基于unicode,一个字节就可以存储数据,不要用两个字节存储,而且这个码表更加的标准化,在每一个字节头加入了编码信息(后期到api中查找)。 能识别中文的码表:GBK、UTF-8;正因为识别中文码表不唯一,涉及到了编码解码问题。 对于我们开发而言;常见的编码 GBK UTF-8 ISO-8859-1 文字--->(数字) :编码。“abc”.getBytes() byte[] (数字)--->文字 : 解码。 byte[] b={97,98,99} new String(b,0,len) 转化流 OutputStreamWriter 是字符流通向字节流的桥梁:可使用指定的字符编码表,将要写入流中的字符编码成字节,将字符串按照指定的编码表转成字节,在使用字节流将这些字节写出去 其实在OutputStreamWriter流中维护自己的缓冲区

Return the Array of Bytes from FileReader()

左心房为你撑大大i 提交于 2019-11-29 04:51:49
I need some help returning the "bytes" variable from this function below to be used as input in another function. function openfile() { var input = document.getElementById("files").files; var fileData = new Blob([input[0]]); var reader = new FileReader(); reader.readAsArrayBuffer(fileData); reader.onload = function(){ var arrayBuffer = reader.result var bytes = new Uint8Array(arrayBuffer); console.log(bytes); } I'd like to get the return of the above function and use the array of bytes as input parameter in another function. You can use promises to wait for the file reader to finish loading

Read and base64 encode a binary file

北慕城南 提交于 2019-11-29 04:08:01
I'm trying to read a binary file from the filesystem and then base64 encode it in JavaScript. I'm using the FileReader API to read the data and the base64 encoder found here . The code I have seems close to working, the problem is that the generated base64 data is wrong. Here's what I've got so far: function saveResource() { var file = $(".resourceFile")[0].files[0]; var reader = new FileReader(); reader.onload = function(evt) { var fileData = evt.target.result; var bytes = new Uint8Array(fileData); var binaryText = ''; for (var index = 0; index < bytes.byteLength; index++) { binaryText +=

Is it possible to load a file with JS/HTML5 FileReader on non served page?

核能气质少年 提交于 2019-11-29 04:01:17
I want to create a simple game in HTML5/JS and I don't want the user to run any webserver or to have to connect to a website. (just an HTML page) But it looks like FileReader can only be used on files type inputs. Is it possible to have only two files : index.html and foo.txt side by side and to read foo.txt from index.html with something like : // No input needed, I know waht I want to read var my_file = new File("foo.txt"); var reader = new FileReader(); alert( reader.readAstext( my_file, "UTF-8" ) ); Any idea ? DRAX I believe that this is your answer: How to open a local disk file with

How can I create a canvas imageData array from an arrayBuffer representation of a JPG

人走茶凉 提交于 2019-11-29 02:07:43
First of all I am aware there are standard methods of achieving this (readAsDataURL and drawImage), but unfortunately they are not usable for this specific use case. I am reading an image using the filereader API as an arraybuffer like so: var reader = new fileReader(); reader.onload = function(e){ var byteArray = new Uint8ClampedArray(e.target.result); //do stuff to this array } reader.readAsArrayBuffer(file); I am then creating a clampedarray with this returned data. What I want to be able to do is now draw this pixel array directly to a canvas using putImageData Currently I am doing the