fileapi

window.resolveLocalFileSystemURL vs window.requestFileSystem

元气小坏坏 提交于 2019-12-05 01:59:35
What is the difference in using window.resolveLocalFileSystemURL vs window.requestFileSystem when downloading files with the cordova file plugin? I cant find any documentation on resolveLocalFileSystemURL but it works fine, and its easier to use? Which one should I use for simple CRUD operations in a cordova app? (I use cordova 3.4.0-0.1.3) I use it like this: function onResolveSuccess(fileEntry) { fileEntry.file(function(file) { var reader = new FileReader(); reader.onloadend = function(evt) { var _machines = JSON.parse(evt.target.result); machinesCache.setMachines(_machines.AllMainCategories

Specifying blob encoding in Google Chrome

梦想的初衷 提交于 2019-12-05 00:54:12
The following code (vendor normalized) works perfectly fine and displays "➀➁➂ Test" in Firefox 8, but displays "➀âžâž‚ Test" in Google Chrome. Is there any way to preserve encoding of blobs in Google Chrome short of writing a file to a temporary filesystem using the filesystem API? var bb = new BlobBuilder; bb.append("➀➁➂ Test"); var b = bb.getBlob("text/plain;charset=UTF-8"); var url = URL.createObjectURL(b); open(url); Gecko (Firefox), WebKit (Safari, Chrome) and Opera support the non-standard btoa function for encoding a string in base 64. In order to get a base 64 string containing a

HTML5 and Javascript : Opening and Reading a Local File with File API

一曲冷凌霜 提交于 2019-12-04 19:43:10
I am using Google Web Toolkit for a project and would like the user to select a text file to open in a text window inside the browser. Here's the almost working code: private DialogBox createUploadBox() { final DialogBox uploadBox = new DialogBox(); VerticalPanel vpanel = new VerticalPanel(); String title = "Select a .gms file to open:"; final FileUpload upload = new FileUpload(); uploadBox.setText(title); uploadBox.setWidget(vpanel); HorizontalPanel buttons = new HorizontalPanel(); HorizontalPanel errorPane = new HorizontalPanel(); Button openButton = new Button( "Open", new ClickHandler() {

Read file stream using JavaScript in web browser

落花浮王杯 提交于 2019-12-04 19:25:32
问题 In web browser, I want to compute sha1 checksum of a huge file in the local filesystem without sending it to a server. File API supports to read files from local disk but I guess it reads the entire of the file and put all of them into the memory. It may occur a problem if the file is larger than system memory. Streams API seems to be useful to solve this problem but I couldn't find how to read a file using the API. Is there any way to read file stream from local disk using javascript in web

Resumable.js: Persist file uploading between redirects and browser restarts

强颜欢笑 提交于 2019-12-04 19:11:36
Is it possible to make file uploads resumable after page redirect / browser restart through Resumable.js or any other Javascript API? (I seriously miss NPAPI here) 来源: https://stackoverflow.com/questions/34131621/resumable-js-persist-file-uploading-between-redirects-and-browser-restarts

File manipulations such as Read/Write local files using Javascript without server

可紊 提交于 2019-12-04 14:34:34
问题 I'm just trying on the task, file manipulation system using java script. As I was referred from W3C File API( https://www.w3.org/TR/FileAPI/ ), we can only read local files like var file = "test.txt"; function readTextFile(file) { var readFile; if(window.XMLHttpRequest){ // for new browsers readFile = new XMLHttpRequest(); }else{ //for old browsers like IE5 or IE6 readFile = new ActiveXObject("Microsoft.XMLHTTP"); } readFile.open("GET", file, true); readFile.onreadystatechange = function() {

Websocket File upload speed issue (Java websocket API and Javascript)

本小妞迷上赌 提交于 2019-12-04 13:41:59
I barely made websocket file upload function. But uploading speed seems to be slow. I have used Java API for websocket Server and javascript for client. Server: package websocket; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.nio.ByteBuffer; import javax.websocket.CloseReason; import javax.websocket.EndpointConfig; import javax.websocket.OnClose; import javax.websocket.OnError; import javax.websocket.OnMessage; import javax.websocket.OnOpen; import javax.websocket.Session; import javax.websocket.server

How to write UTF-8 or Base64 data into a file (jpg/doc/pdf) on local storage(sdcard) in Phonegap

半城伤御伤魂 提交于 2019-12-04 11:25:58
问题 I am getting byte array like var byteArr=[12,-123,43,99, ...] from API, Then I am converting it into UTF-8 String by var utf8_str = String.fromCharCode.apply([], new Uint8Array(byteArr)); Then converting UTF-8 string to Base64 string by var base64_str= window.btoa(utf8_str); Now I am writing UTF-8 or Base64 string to file (xyz.pdf/xyz.jpg) by FileWriter in Phonegap, but it show me blank file when open it. function gotWriteFile(dirEntry) { dirEntry.getFile(FILE_NAME, {create: true, exclusive:

Html5's File API - BLOB usages?

最后都变了- 提交于 2019-12-04 07:29:13
问题 I have a file input : (jsbin) <input type="file" accept="image/*" id="input" multiple onchange='handleFiles(this)' /> Which , when file selected, shows small images of the selected image : I can do it in two ways : using FileReader : function handleFiles(t) //t=this { var fileList = t.files; for (var i = 0; i < fileList.length; i++) { var file = fileList[i]; var img = document.createElement("img"); img.style... = ... document.getElementById('body').appendChild(img); var reader = new

Fast low-collision non-crypto hash in JavaScript for Files

二次信任 提交于 2019-12-04 06:49:19
I am looking for a fast hash with low collisions implemented in JavaScript. It doesn't need to be a crypto hash. I am basically using it as a way to see if a given file has already been uploaded (or partially uploaded) to a user's account to save them some upload time on large (video) files. I am using the new HTML5 File API to read in slices of the file. I then hand this off to SparkMD5 to give me a hash of the file. I like the fact that SparkMD5 allows me to do an incremental hash so I don't have to read the entire thing in memory. Overall, SparkMD5 works for my needs but for large files it