fileapi

Angular 2 download .CSV file click event with authentication

放肆的年华 提交于 2019-11-29 18:38: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

What and where exactly are privileged code, chrome code, Gecko?

陌路散爱 提交于 2019-11-29 17:55:10
In reading about the File API and wanting to write data directly from an indexedDB database to the client disk instead of first building and holding a large blob in RAM to download to disk, there are a few basic items I'm not understanding. In the MDN documents these two statements are found: In Gecko, privileged code can create File objects representing any local file without user interaction. If you want to use the DOM File API in chrome code, you can do so without restriction. In fact, you get one bonus feature: you can create File objects specifying the path of the file on the user's

Select & Drop Files and/or Folders to be parsed

有些话、适合烂在心里 提交于 2019-11-29 08:58:33
I've used a part from a post here on SO ( I can't remember it though ) to parse files and folders on Chrome, but I cannot get it to work on Firefox (and to be honest I haven't tried it on others, though I think it doesn't work on safari either). Here's the 2 directives, ngDrop and input. angular.module('myApp').directive("ngDrop", function($rootScope) { var link = function($scope, elements, attr, ngModel) { var parseInput = function(event) { var list = []; $scope.count = 0; var toParse = []; for (var i = 0; i < event.dataTransfer.items.length; i++) { toParse.push(event.dataTransfer.items[i]

How to read files from folder

断了今生、忘了曾经 提交于 2019-11-29 08:09:32
Found this article which showing how to distinguish file upload from directory How to handle dropped folders but they not explain how I can handle the directory upload. Having difficulties to find any example. Anyone know how to get File instance of each file in directory? Copied from that article: <div id=”dropzone”></div> var dropzone = document.getElementById('dropzone'); dropzone.ondrop = function(e) { var length = e.dataTransfer.items.length; for (var i = 0; i < length; i++) { var entry = e.dataTransfer.items[i].webkitGetAsEntry(); if (entry.isFile) { ... // do whatever you want } else if

JS and type.match as file mime type - need advice

為{幸葍}努か 提交于 2019-11-29 07:04:47
Today I faced an interesting thing as FF File API and separate files by their types. OK here is a little snippet as if (!input.files[0].type.match('image.*')) { window.alert("Select image please"); return; } it controls image being read only. But what about doc files and pdf for example? I couldn't find useful examples for this thing so I hope you can share some snippets. The thing I am interested in detecting different file types but how can I control different file types with JS and its type.match bound? Here is the base code Any useful comment is appreciated :) So the base idea is that this

Filesystem API not working in Chrome v27 & v29

梦想的初衷 提交于 2019-11-29 05:02:50
问题 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) { //

HTML5 and Amazon S3 Multi-Part uploads

可紊 提交于 2019-11-29 02:53:36
问题 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 回答1: 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

“undefined” returned when accessing some listed properties of File object

℡╲_俬逩灬. 提交于 2019-11-28 21:55:21
I can't seem to access the width or height keys of my object. I'm using dropzone.js which has an event for addedFile which returns the file and the first param. so: var myDropzone = new Dropzone('#dropzone', {url: '/'}); myDropzone.on('addedFile', function(file) { console.log(file); }); The callback works just fine, in my console I see: As you can see, there's clearly the height & width keys available. myDropzone.on('addedFile', function(file) { console.log(file.name); // returns the whole strong console.log(file.width); // returns undefined console.log(file['width']); // returns undefined });

How to create File object from Blob?

╄→гoц情女王★ 提交于 2019-11-28 20:10:37
DataTransferItemList.add allows you to override copy operation in javascript. It, however, only accepts File object. Copy event The code in my copy event: var items = (event.clipboardData || event.originalEvent.clipboardData); var files = items.items || items.files; if(files) { var blob = Blob.fromDataURL(_this.editor.selection.getSelectedImage().toDataURL("image/png")); files.add(blob); } The error in chrome: Uncaught TypeError: Failed to execute add on DataTransferItemList : parameter 1 is not of type File . Trying the new File(Blob blob, DOMString name) In Google Chrome I tried this,

IOS6 and Safari Photo Uploading - File API + Canvas + jQuery Ajax Uploading and Resizing Files Asynchronously

五迷三道 提交于 2019-11-28 16:33:00
问题 IOS6 has been released and I've been testing photo uploading. It works well, but with larger images over 3G it is SLOW as expected. Thanks to File API and Canvas, it is possible to resize images using JavaScript. I hope that if I resize the images before I attempt to upload them, they will upload faster - lending itself to a speedy user experience. With smartphone processors improving exponentially faster than the network speeds, I believe this solution is a winner. Nicolas has offered an