Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
jio
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Roque
jio
Commits
bd8579dd
Commit
bd8579dd
authored
Jul 02, 2018
by
Vincent Bechu
Committed by
Vincent Bechu
Aug 06, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[util] Add base64toBlob function
parent
b345214e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
10 deletions
+15
-10
src/jio.js
src/jio.js
+15
-10
No files found.
src/jio.js
View file @
bd8579dd
...
@@ -165,27 +165,32 @@
...
@@ -165,27 +165,32 @@
}
}
util
.
stringify
=
stringify
;
util
.
stringify
=
stringify
;
function
base64toBlob
(
b64String
,
mimeString
)
{
// https://gist.github.com/davoclavo/4424731
var
byteString
=
atob
(
b64String
),
function
dataURItoBlob
(
dataURI
)
{
if
(
dataURI
===
'
data:
'
)
{
return
new
Blob
();
}
// convert base64 to raw binary data held in a string
var
byteString
=
atob
(
dataURI
.
split
(
'
,
'
)[
1
]),
// separate out the mime component
mimeString
=
dataURI
.
split
(
'
,
'
)[
0
].
split
(
'
:
'
)[
1
],
// write the bytes of the string to an ArrayBuffer
// write the bytes of the string to an ArrayBuffer
arrayBuffer
=
new
ArrayBuffer
(
byteString
.
length
),
arrayBuffer
=
new
ArrayBuffer
(
byteString
.
length
),
_ia
=
new
Uint8Array
(
arrayBuffer
),
_ia
=
new
Uint8Array
(
arrayBuffer
),
i
;
i
;
mimeString
=
mimeString
.
slice
(
0
,
mimeString
.
length
-
"
;base64
"
.
length
);
for
(
i
=
0
;
i
<
byteString
.
length
;
i
+=
1
)
{
for
(
i
=
0
;
i
<
byteString
.
length
;
i
+=
1
)
{
_ia
[
i
]
=
byteString
.
charCodeAt
(
i
);
_ia
[
i
]
=
byteString
.
charCodeAt
(
i
);
}
}
return
new
Blob
([
arrayBuffer
],
{
type
:
mimeString
});
return
new
Blob
([
arrayBuffer
],
{
type
:
mimeString
});
}
}
util
.
base64toBlob
=
base64toBlob
;
// https://gist.github.com/davoclavo/4424731
function
dataURItoBlob
(
dataURI
)
{
if
(
dataURI
===
'
data:
'
)
{
return
new
Blob
();
}
// convert base64 to raw binary data held in a string
var
mimeString
=
dataURI
.
split
(
'
,
'
)[
0
].
split
(
'
:
'
)[
1
];
mimeString
=
mimeString
.
slice
(
0
,
mimeString
.
length
-
"
;base64
"
.
length
);
return
base64toBlob
(
dataURI
.
split
(
'
,
'
)[
1
],
mimeString
);
}
util
.
dataURItoBlob
=
dataURItoBlob
;
util
.
dataURItoBlob
=
dataURItoBlob
;
// tools
// tools
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment