Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #35239
| Path | csiph.com!xmission!eternal-september.org!feeder.eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | Jake Jarvis <pig_in_shoes@yahoo.com> |
| Newsgroups | comp.lang.javascript |
| Subject | Re: Array of Files to array of data url |
| Date | Tue, 19 Jun 2018 12:28:52 +0200 |
| Organization | A noiseless patient Spider |
| Lines | 31 |
| Message-ID | <pgalt3$hdf$1@dont-email.me> (permalink) |
| References | <8dGdnZA1WKvpTbXGnZ2dnUU7-e3NnZ2d@westnet.com.au> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=utf-8; format=flowed |
| Content-Transfer-Encoding | 8bit |
| Injection-Date | Tue, 19 Jun 2018 10:28:51 -0000 (UTC) |
| Injection-Info | reader02.eternal-september.org; posting-host="832fcc06ea533265a9eed92a23d68efc"; logging-data="17839"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/2/tcPGZyX/ezAZ8NsMTakqDCP9u/VuTY=" |
| User-Agent | Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 |
| Cancel-Lock | sha1:zWOUHrV6sAO94c1DJ0DzH1pkDf4= |
| In-Reply-To | <8dGdnZA1WKvpTbXGnZ2dnUU7-e3NnZ2d@westnet.com.au> |
| Xref | csiph.com comp.lang.javascript:35239 |
Show key headers only | View raw
Am 19.06.2018 um 11:44 schrieb Andrew Poulos:
> I have this array
>
> var files = [File, File, null, File];
>
> and I need to create a new array with the data from each File (or null
> if it's null).
>
> I tried
>
> var newarr = files.map(function(el){
> if (el === null) return null;
>
> var reader = new FileReader();
>
> reader.addEventListener("load", function () {
> return reader.result;
> }, false);
>
> reader.readAsDataURL(el);
> });
>
> but the array only ever gets populated with null. How can this be done?
>
> Andrew Poulos
File API is asynchronous. ("Don't call us, we'll call you")
No idea what the big picture is, maybe those new Promise things can help.
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Array of Files to array of data url Andrew Poulos <ap_prog@hotmail.com> - 2018-06-19 19:44 +1000
Re: Array of Files to array of data url Jake Jarvis <pig_in_shoes@yahoo.com> - 2018-06-19 12:28 +0200
Re: Array of Files to array of data url Jon Ribbens <jon+usenet@unequivocal.eu> - 2018-06-19 14:47 +0000
Re: Array of Files to array of data url Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2018-06-20 21:47 +0200
Re: Array of Files to array of data url Andrew Poulos <ap_prog@hotmail.com> - 2018-06-21 15:33 +1000
Re: Array of Files to array of data url "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2018-06-21 15:16 -0700
csiph-web