Timeline for Convert blob to base64
Current License: CC BY-SA 4.0
27 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Feb 19 at 13:03 | comment | added | milahu |
this is function blobToDataUrl
|
|
May 30, 2022 at 17:58 | comment | added | Jason C | I.e. it will never fire "between lines of code"; the only opportunities it has is either during async awaits, or after the script has been fully executed. Also, on a higher level, W3C went to great lengths to build determinism into the web specs; and if it wasn't there in this case, most things just... wouldn't work -- in particular, API objects that begin firing events as soon as they are constructed would be essentially unusable. | |
May 30, 2022 at 17:52 | comment | added | Jason C |
@3ocene No, it can't. The File API spec defines read ops; and loadend is never fired directly, as all paths to loadend queue the event task on the file reading task source, whose implied event loop is the same one that's executing the script.
|
|
May 30, 2022 at 17:34 | comment | added | Jason C |
@JoshuaSmith Yeah; I dunno, I mean, you could just use btoa(await blob.text()) and skip all this extra strangeness. Maybe btoa wasn't around in 2013?
|
|
Oct 12, 2021 at 18:08 | history | edited | patelarpan | CC BY-SA 4.0 |
added 238 characters in body
|
S Aug 24, 2021 at 6:04 | history | suggested | joe | CC BY-SA 4.0 |
add function version
|
Aug 20, 2021 at 19:09 | review | Suggested edits | |||
S Aug 24, 2021 at 6:04 | |||||
S Jul 18, 2020 at 7:14 | history | rollback | Arun Killu |
Rollback to Revision 5 - Edit approval overridden by post owner or moderator
|
|
Jul 18, 2020 at 4:45 | history | suggested | Mingwei Samuel | CC BY-SA 4.0 |
set handlers before calling
|
Jul 18, 2020 at 3:39 | review | Suggested edits | |||
S Jul 18, 2020 at 7:14 | |||||
Jun 23, 2020 at 20:13 | comment | added | 3ocene |
@CristianTraìna readAsDataURL is a function call, and could, therefore, complete the entire load (including calling the event listeners) before the function returns. This is not how the function is implemented in every environment I know of, but JavaScript being single-threaded doesn't have anything to do with it. Furthermore, all it takes is for some junior developer to come along and unwittingly add an await statement or something in there, and suddenly you have a bug that is incredibly difficult to troubleshoot. As I said, "obviously this would never happen but it's still good practice."
|
|
Jun 23, 2020 at 13:57 | comment | added | Christian Vincenzo Traina | @3ocene that can't happen. JavaScript is single-threaded, nothing weird can happen in the while. | |
Mar 15, 2020 at 21:23 | comment | added | therightstuff | combined with stackoverflow.com/a/11901662/2860309 for reading from a blob url, this really helped! | |
Aug 9, 2019 at 9:16 | history | edited | lapinkoira | CC BY-SA 4.0 |
added 4 characters in body
|
S Jan 3, 2018 at 22:09 | history | suggested | CommunityBot | CC BY-SA 3.0 |
fixed indentation, removed unnecessary window
|
Jan 3, 2018 at 19:44 | review | Suggested edits | |||
S Jan 3, 2018 at 22:09 | |||||
Jan 19, 2016 at 23:41 | comment | added | Joshua Smith | This answer is incorrect, it appends none-base64 characters to the front of the string. | |
Dec 16, 2015 at 6:00 | comment | added | 3ocene |
onloadend should come before readAsDataURL just in case something weird happens and it finishes loading before it reaches the next line of code. Obviously this would never happen but it's still good practice.
|
|
Aug 3, 2015 at 18:59 | comment | added | palota | console.log( base64data.substr(base64data.indexOf(',')+1) ); | |
Jun 12, 2015 at 6:10 | comment | added | Mrug |
But, Concern is how to get just Base64 String from that instead of those other tags, e.g. I am getting data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAB4AAAAQ4CAYAAADo08FDAAAKoWlDQ…ApOxJ4m+EDQbZE3wR+j7XSz2unTElvZ+s/1Vw/8B6sw4fipgOycAAAAASUVORK5CYII= but I want just : iVBORw0KGgoAAAANSUhEUgAAB4AAAAQ4CAYAAADo08FDAAAKoWlDQ…ApOxJ4m+EDQbZE3wR+j7XSz2unTElvZ+s/1Vw/8B6sw4fipgOycAAAAASUVORK5CYII=
|
|
Apr 27, 2014 at 3:02 | vote | accept | quarks | ||
Apr 26, 2014 at 5:29 | comment | added | Nawaf Alsulami | @xybrek If you print read.result, you will see base64 in the string itself. | |
Jan 4, 2014 at 18:30 | history | edited | Arun Killu | CC BY-SA 3.0 |
deleted 16 characters in body
|
Sep 9, 2013 at 4:22 | history | edited | Arun Killu | CC BY-SA 3.0 |
added 148 characters in body
|
Sep 9, 2013 at 1:07 | comment | added | quarks | The output String doesn't seem to look like base64? | |
Sep 6, 2013 at 5:20 | review | Low quality answers | |||
Sep 6, 2013 at 5:24 | |||||
Sep 6, 2013 at 5:05 | history | answered | Arun Killu | CC BY-SA 3.0 |