fileapi

Work around for Html5 Local File Access

天涯浪子 提交于 2019-11-30 23:30:58
We are currently looking at porting a enterprise silverlight application over to html5. The major roadblock that we have hit is the ability to open files from the user's local disk. Currently they have a document library which just links to files on their computer that they can open from within the app and view or print out. All that I read is that you can only access the local sandbox of the web app with the html5 file api's. We want to load these files from code. Does anyone know of any workarounds to this? Thanks There is no way for html5 to access local file without user selection. But FSO

How to create a File object from binary data in JavaScript

痴心易碎 提交于 2019-11-30 21:42:29
I'm probably missing something simple here, but how would I create a File object in JavaScript given the binary data as received from an AJAX request? $.ajax({ url: "http://example.com/image.jpg", success: function(data) { // Convert binary data to File object } }); I finally figured this out. In order to avoid cross-site scripting issues, I created a proxy endpoint on my server. Then I can pass the image URL to my server, which then executes a GET request on the remote file, converts the response to Base64, and sends it back to the browser. The browser can then convert the data back to binary

HTML5 FIle API: Security Error while reading a file

我是研究僧i 提交于 2019-11-30 17:49:02
Problem solved, read comment The third problem I have with the HTML5 File API: I still use Chrome 12 on Mac OS X Snow Leopard and I'm still trying to read files with the HTML5 File API, but FileHandler.error() get called because a "SECURITY_ERR" occurres. The file I try to read is a regular .txt file from my desktop, but it neither works with other files although I can open them with regular applications. function FileHandler(files, action) { console.log('FileHandler called.'); this.files = files; this.reader = new FileReader(); this.action = action; this.handle = function() { console.log(

How can i generate a file and offer it for download in plain javascript?

こ雲淡風輕ζ 提交于 2019-11-30 14:45:38
I would like to generate a text file in the javascript dynamicly, then offer this for download. Currently I can get this working to a degree with either of the following solutions: content = "abc123"; document.location = "data:text/octet-stream," + encodeURIComponent(content); OR content = "abc123"; var bb = new BlobBuilder(); bb.append(content); var blob = bb.getBlob(); blob = blob.slice(0, blob.size, 'text/octet-stream'); var fr = new FileReader(); fr.onload = function() {document.location = this.result;} fr.readAsDataURL(blob); However, Both of these solutions, when the download box appears

Angular 2 download .CSV file click event with authentication

断了今生、忘了曾经 提交于 2019-11-30 12:48:20
I'm using a spring boot backend and my api uses a service to send data via an OutputStreamWriter. I can download this in Angular 2 using a click event like so: Typescript results(){ window.location.href='myapicall'; } HTML <button (click)="results()" class="btn btn-primary">Export</button> This works just fine; however, I recently implemented security for my api endpoints and now I am receiving a 401 everytime I try to make the call because it's not sending a header. I wrote a service that I can see the results in the console, but I can't seem to figure out how to download the file.

overwrite a file with HTML5 FileWriter

余生颓废 提交于 2019-11-30 11:44:14
I'm using HTML5 FileWriter API to save the state of my webapp. I have bit of JS that periodically calls FileWriter.write to do that (so , over time, the write method is called several times). By default FileWriter API use an 'append' approach to writing files which does not suits my needs since I wan't to overwrite the file content. I first tried this: this._writer.seek(0); this._writer.write(content); This is not working when you are writing a text shorter than the file content. I then tried this: this._writer.truncate(0); this._writer.write(content); This code is supposed to clear the file

Filesystem API not working in Chrome v27 & v29

╄→尐↘猪︶ㄣ 提交于 2019-11-30 05:41:39
I'm trying to set up a file storage for later use in Phonegap, but debugging in Chrome for now. Going the way as described on html5rocks only lets me request a quota from the user, but the callback when requesting the filesystem is not executed. See: window.webkitStorageInfo.requestQuota(PERSISTENT, 1024*1024*1024, function(grantedBytes) { requestFS(grantedBytes); }, onError); function requestFS(grantedBytes) { window.webkitRequestFileSystem(window.PERSISTENT, grantedBytes, function(fs) { // ... does not get called ################################### }, onError); } Now Chrome warns me that

HTML5 and Amazon S3 Multi-Part uploads

假装没事ソ 提交于 2019-11-30 05:19:20
Is it possible to use the HTML 5 File API (for example, this library: https://github.com/23/resumable.js ) in conjunction with the S3 multi-part upload feature? http://docs.aws.amazon.com/AmazonS3/latest/dev/uploadobjusingmpu.html Yes, but you will need some kind of server backend to handle the Amazon API keys in a more secure way if you are going to make it part of a public website. You can find what looks like a complete example implementation of this these projects: s3-multipart-upload-browser which uses a PHP backend s3_multipart which uses Ruby. Please note that I have not used, tested or

Javascript/HTML5 file API reading sequential files into multipart form data

百般思念 提交于 2019-11-29 22:11:07
问题 I'm using the HTML5 File API to assemble multipart form data for submission by XHR to a web service. I have the whole thing working in FF, which has a nice convenient getAsBinary() method included in their implementation of the file API. This was a pretty sweet deal. It basically went: var const; // constructor const += headers; const += field_data; for(var i = 0; i < files.length; i++) { const += files[i].getAsBinary(); } sendData(const); Worked like a charm. To get it working in Chrome,

How can i generate a file and offer it for download in plain javascript?

痴心易碎 提交于 2019-11-29 21:55:32
问题 I would like to generate a text file in the javascript dynamicly, then offer this for download. Currently I can get this working to a degree with either of the following solutions: content = "abc123"; document.location = "data:text/octet-stream," + encodeURIComponent(content); OR content = "abc123"; var bb = new BlobBuilder(); bb.append(content); var blob = bb.getBlob(); blob = blob.slice(0, blob.size, 'text/octet-stream'); var fr = new FileReader(); fr.onload = function() {document.location