fileapi

Getting md5sum of a file through Crypto.js

半世苍凉 提交于 2021-02-07 03:29:33
问题 I am trying to get the md5sum of a tar file to produce the same value when using the md5sum linux command and CryptoJS's MD5 method. In JavaScript I do (after a file has been put in an HTML form): var reader = new FileReader(); reader.onloadend = function () { text = (reader.result); } reader.readAsBinaryString(document.getElementById("firmware_firmware").files[0]); var hash = CryptoJS.MD5(text); hash.toString(); In Linux I do: md5sum name_of_file.tar Currently these two produce different

Getting md5sum of a file through Crypto.js

好久不见. 提交于 2021-02-07 03:24:35
问题 I am trying to get the md5sum of a tar file to produce the same value when using the md5sum linux command and CryptoJS's MD5 method. In JavaScript I do (after a file has been put in an HTML form): var reader = new FileReader(); reader.onloadend = function () { text = (reader.result); } reader.readAsBinaryString(document.getElementById("firmware_firmware").files[0]); var hash = CryptoJS.MD5(text); hash.toString(); In Linux I do: md5sum name_of_file.tar Currently these two produce different

Getting md5sum of a file through Crypto.js

久未见 提交于 2021-02-07 03:23:18
问题 I am trying to get the md5sum of a tar file to produce the same value when using the md5sum linux command and CryptoJS's MD5 method. In JavaScript I do (after a file has been put in an HTML form): var reader = new FileReader(); reader.onloadend = function () { text = (reader.result); } reader.readAsBinaryString(document.getElementById("firmware_firmware").files[0]); var hash = CryptoJS.MD5(text); hash.toString(); In Linux I do: md5sum name_of_file.tar Currently these two produce different

Accessing partial results of a FileReader in Firefox

♀尐吖头ヾ 提交于 2021-01-28 11:55:57
问题 I want to use a FileReader in my web application to partially load a CSV file into the browser. However, I am not able to access partial results in Firefox 27. My application requires only the first 100k bytes of the CSV file to populate a data preview. Therefore, I setup, start, and then abort the reader after a certain amount of data has been loaded. Here is an example that works fine in Chrome 35: warn = (a...) -> console.warn a... readFile = (file,cb,limit=1e5) -> warn "start reading file

file.slice fails second time

喜夏-厌秋 提交于 2020-06-29 03:59:06
问题 I'm trying to make a (front-end) Javascript that would be able to copy very large files (i.e. read them from a file input element and 'download' them using StreamSaver.js). This is the actual code: <html> <header> <title>File copying</title> </header> <body> <script src="https://cdn.jsdelivr.net/npm/web-streams-polyfill@2.0.2/dist/ponyfill.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/streamsaver@2.0.3/StreamSaver.min.js"></script> <script type="text/javascript"> const

file.slice fails second time

烂漫一生 提交于 2020-06-29 03:58:14
问题 I'm trying to make a (front-end) Javascript that would be able to copy very large files (i.e. read them from a file input element and 'download' them using StreamSaver.js). This is the actual code: <html> <header> <title>File copying</title> </header> <body> <script src="https://cdn.jsdelivr.net/npm/web-streams-polyfill@2.0.2/dist/ponyfill.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/streamsaver@2.0.3/StreamSaver.min.js"></script> <script type="text/javascript"> const

File object to image with correct file name instead of src=“blob…”

岁酱吖の 提交于 2020-01-13 10:15:05
问题 I have a File object myFile that looks like this in console: File { name: "myimage.jpg", lastModified: 1465476925001, lastModifiedDate: Thu Jun 09 2016 14:55:25 GMT+0200 (CEST), size: 33002 type: "image/jpeg" } But when i create an image out of it with var image = new Image(); image.src = URL.createObjectURL(myFile); I get: <img src="blob:http://myurl.com/6b2b83d8-ac36-40c1-8ab1-c4f07b019ba5"> When i try to save the file with right-click, the file-name is empty or "6b2b83d8-ac36-40c1-8ab1

File object to image with correct file name instead of src=“blob…”

十年热恋 提交于 2020-01-13 10:14:05
问题 I have a File object myFile that looks like this in console: File { name: "myimage.jpg", lastModified: 1465476925001, lastModifiedDate: Thu Jun 09 2016 14:55:25 GMT+0200 (CEST), size: 33002 type: "image/jpeg" } But when i create an image out of it with var image = new Image(); image.src = URL.createObjectURL(myFile); I get: <img src="blob:http://myurl.com/6b2b83d8-ac36-40c1-8ab1-c4f07b019ba5"> When i try to save the file with right-click, the file-name is empty or "6b2b83d8-ac36-40c1-8ab1

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

↘锁芯ラ 提交于 2020-01-13 06:55:42
问题 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();