Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
jio_mebibou
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
Alexandra Rogova
jio_mebibou
Commits
f434f44d
Commit
f434f44d
authored
Jan 22, 2019
by
Guillaume Royer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(node): handle Blob response in ajax
parent
c197abf5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
5 deletions
+20
-5
src/node/jio.js
src/node/jio.js
+20
-5
No files found.
src/node/jio.js
View file @
f434f44d
...
...
@@ -18,13 +18,20 @@
* See https://www.nexedi.com/licensing for rationale and options.
*/
/*global window */
(
function
(
window
,
jIO
,
Blob
)
{
/*global window
, ArrayBuffer
*/
(
function
(
window
,
jIO
,
Blob
,
ArrayBuffer
)
{
"
use strict
"
;
var
FormData
,
originalAjax
;
function
convertToBlob
(
evt
,
convert
)
{
if
(
convert
&&
evt
.
target
.
response
instanceof
ArrayBuffer
)
{
evt
.
target
.
response
=
new
Blob
([
evt
.
target
.
response
]);
}
return
evt
;
}
// https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/
// Using_XMLHttpRequest#Submitting_forms_and_uploading_files
FormData
=
function
FormData
()
{
...
...
@@ -43,11 +50,17 @@
originalAjax
=
jIO
.
util
.
ajax
;
jIO
.
util
.
ajax
=
function
ajax
(
param
)
{
var
convertToArrayBuffer
=
param
.
dataType
===
'
blob
'
;
if
(
convertToArrayBuffer
)
{
param
.
dataType
=
'
arraybuffer
'
;
}
if
(
param
.
data
instanceof
Blob
)
{
// Blob is not supported by xhr2, so convert to ArrayBuffer instead
return
jIO
.
util
.
readBlobAsArrayBuffer
(
param
.
data
).
then
(
function
(
data
)
{
param
.
data
=
data
.
target
.
result
;
return
originalAjax
(
param
);
return
originalAjax
(
param
).
then
(
function
(
evt
)
{
return
convertToBlob
(
evt
,
convertToArrayBuffer
);
});
});
}
...
...
@@ -63,10 +76,12 @@
return
originalAjax
(
param
);
}
return
originalAjax
(
param
);
return
originalAjax
(
param
).
then
(
function
(
evt
)
{
return
convertToBlob
(
evt
,
convertToArrayBuffer
);
});
};
}(
window
,
window
.
jIO
,
window
.
Blob
));
}(
window
,
window
.
jIO
,
window
.
Blob
,
ArrayBuffer
));
// Define a global variable to allow storages to access jIO
var
jIO
=
window
.
jIO
,
...
...
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