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
amrani
jio
Commits
f4a45ae1
Commit
f4a45ae1
authored
Apr 02, 2015
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
getAttachment: directly returns the blob instead of a JSON object
parent
d9e77f60
Changes
17
Show whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
51 additions
and
51 deletions
+51
-51
src/jio.js
src/jio.js
+1
-1
src/jio.storage/davstorage.js
src/jio.storage/davstorage.js
+2
-2
src/jio.storage/documentstorage.js
src/jio.storage/documentstorage.js
+1
-1
src/jio.storage/drivetojiomapping.js
src/jio.storage/drivetojiomapping.js
+1
-1
src/jio.storage/erp5storage.js
src/jio.storage/erp5storage.js
+6
-6
src/jio.storage/indexeddbstorage.js
src/jio.storage/indexeddbstorage.js
+1
-1
src/jio.storage/localstorage.js
src/jio.storage/localstorage.js
+1
-1
src/jio.storage/memorystorage.js
src/jio.storage/memorystorage.js
+1
-1
test/jio.storage/davstorage.tests.js
test/jio.storage/davstorage.tests.js
+3
-3
test/jio.storage/documentstorage.tests.js
test/jio.storage/documentstorage.tests.js
+6
-6
test/jio.storage/drivetojiomapping.tests.js
test/jio.storage/drivetojiomapping.tests.js
+4
-4
test/jio.storage/erp5storage.tests.js
test/jio.storage/erp5storage.tests.js
+9
-9
test/jio.storage/indexeddbstorage.tests.js
test/jio.storage/indexeddbstorage.tests.js
+4
-4
test/jio.storage/localstorage.tests.js
test/jio.storage/localstorage.tests.js
+5
-5
test/jio.storage/memorystorage.tests.js
test/jio.storage/memorystorage.tests.js
+2
-2
test/jio.storage/querystorage.tests.js
test/jio.storage/querystorage.tests.js
+2
-2
test/jio.storage/uuidstorage.tests.js
test/jio.storage/uuidstorage.tests.js
+2
-2
No files found.
src/jio.js
View file @
f4a45ae1
...
...
@@ -339,7 +339,7 @@
checkId
(
param
,
storage
,
method_name
);
checkAttachmentId
(
param
,
storage
,
method_name
);
},
function
(
argument_list
,
result
)
{
if
(
!
(
result
.
data
instanceof
Blob
))
{
if
(
!
(
result
instanceof
Blob
))
{
throw
new
jIO
.
util
.
jIOError
(
"
'getAttachment' (
"
+
argument_list
[
0
].
_id
+
"
,
"
+
argument_list
[
0
].
_attachment
+
"
) on '
"
+
this
.
__type
+
...
...
src/jio.storage/davstorage.js
View file @
f4a45ae1
...
...
@@ -186,11 +186,11 @@
});
})
.
push
(
function
(
response
)
{
return
{
data
:
new
Blob
(
return
new
Blob
(
[
response
.
target
.
response
||
response
.
target
.
responseText
],
{
"
type
"
:
response
.
target
.
getResponseHeader
(
'
Content-Type
'
)
||
"
application/octet-stream
"
}
)
}
;
);
},
function
(
error
)
{
if
((
error
.
target
!==
undefined
)
&&
(
error
.
target
.
status
===
404
))
{
...
...
src/jio.storage/documentstorage.js
View file @
f4a45ae1
...
...
@@ -35,7 +35,7 @@
"
_attachment
"
:
getSubAttachmentIdFromParam
(
param
)
})
.
push
(
function
(
blob
)
{
return
jIO
.
util
.
readBlobAsText
(
blob
.
data
);
return
jIO
.
util
.
readBlobAsText
(
blob
);
})
.
push
(
function
(
text
)
{
return
JSON
.
parse
(
text
.
target
.
result
);
...
...
src/jio.storage/drivetojiomapping.js
View file @
f4a45ae1
...
...
@@ -36,7 +36,7 @@
.
push
(
function
(
blob
)
{
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
return
jIO
.
util
.
readBlobAsText
(
blob
.
data
);
return
jIO
.
util
.
readBlobAsText
(
blob
);
})
.
push
(
function
(
text
)
{
explicit_document
=
true
;
...
...
src/jio.storage/erp5storage.js
View file @
f4a45ae1
...
...
@@ -106,19 +106,19 @@
// if Base_edit, do put URN
// if others, do post URN (ie, unique new attachment name)
// XXX Except this attachment name should be generated when
return
{
data
:
new
Blob
(
return
new
Blob
(
[
JSON
.
stringify
(
result
)],
{
"
type
"
:
'
application/hal+json
'
}
)
}
;
);
});
}
if
(
action
===
"
links
"
)
{
return
getDocumentAndHateoas
(
this
,
param
)
.
push
(
function
(
response
)
{
return
{
data
:
new
Blob
(
return
new
Blob
(
[
JSON
.
stringify
(
JSON
.
parse
(
response
.
target
.
responseText
))],
{
"
type
"
:
'
application/hal+json
'
}
)
}
;
);
});
}
if
(
action
.
indexOf
(
this
.
_url
)
===
0
)
{
...
...
@@ -135,10 +135,10 @@
.
push
(
function
(
evt
)
{
var
result
=
JSON
.
parse
(
evt
.
target
.
responseText
);
result
.
_id
=
param
.
_id
;
return
{
data
:
new
Blob
(
return
new
Blob
(
[
JSON
.
stringify
(
result
)],
{
"
type
"
:
evt
.
target
.
getResponseHeader
(
"
Content-Type
"
)}
)
}
;
);
});
}
throw
new
jIO
.
util
.
jIOError
(
"
ERP5: not support get attachment:
"
+
action
,
...
...
src/jio.storage/indexeddbstorage.js
View file @
f4a45ae1
...
...
@@ -327,7 +327,7 @@
array_buffer_list
.
push
(
result_list
[
i
].
blob
);
}
blob
=
new
Blob
(
array_buffer_list
,
{
type
:
"
application/octet-stream
"
});
return
{
data
:
blob
.
slice
(
start
,
end
)}
;
return
blob
.
slice
(
start
,
end
)
;
});
};
...
...
src/jio.storage/localstorage.js
View file @
f4a45ae1
...
...
@@ -89,7 +89,7 @@
404
);
}
return
{
data
:
dataURItoBlob
(
textstring
)}
;
return
dataURItoBlob
(
textstring
)
;
};
LocalStorage
.
prototype
.
putAttachment
=
function
(
param
)
{
...
...
src/jio.storage/memorystorage.js
View file @
f4a45ae1
...
...
@@ -88,7 +88,7 @@
404
);
}
return
{
data
:
result
}
;
return
result
;
}
catch
(
error
)
{
if
(
error
instanceof
TypeError
)
{
throw
new
jIO
.
util
.
jIOError
(
...
...
test/jio.storage/davstorage.tests.js
View file @
f4a45ae1
...
...
@@ -858,9 +858,9 @@
Authorization
:
"
Basic login:passwd
"
});
ok
(
result
.
data
instanceof
Blob
,
"
Data is Blob
"
);
deepEqual
(
result
.
data
.
type
,
"
text/plain
"
,
"
Check mimetype
"
);
return
jIO
.
util
.
readBlobAsText
(
result
.
data
);
ok
(
result
instanceof
Blob
,
"
Data is Blob
"
);
deepEqual
(
result
.
type
,
"
text/plain
"
,
"
Check mimetype
"
);
return
jIO
.
util
.
readBlobAsText
(
result
);
})
.
then
(
function
(
result
)
{
equal
(
result
.
target
.
result
,
"
foo
\n
baré
"
,
...
...
test/jio.storage/documentstorage.tests.js
View file @
f4a45ae1
...
...
@@ -53,11 +53,11 @@
deepEqual
(
options
,
{
"
_id
"
:
"
foo
"
,
"
_attachment
"
:
"
jio_document/YmFy.json
"
},
"
getAttachment bar
"
);
return
{
data
:
new
Blob
([
JSON
.
stringify
({
return
new
Blob
([
JSON
.
stringify
({
title
:
options
.
_attachment
,
id
:
"
ID
"
+
options
.
_attachment
,
"
another
"
:
"
property
"
})])
}
;
})]);
};
StorageGetNoAttachment
.
prototype
.
get
=
function
(
options
)
{
deepEqual
(
options
,
{
"
_id
"
:
"
foo
"
},
"
Get foo
"
);
...
...
@@ -106,11 +106,11 @@
deepEqual
(
options
,
{
"
_id
"
:
"
foo
"
,
"
_attachment
"
:
"
jio_document/YmFy.json
"
},
"
getAttachment bar
"
);
return
{
data
:
new
Blob
([
JSON
.
stringify
({
return
new
Blob
([
JSON
.
stringify
({
title
:
options
.
_attachment
,
id
:
"
ID
"
+
options
.
_attachment
,
"
another
"
:
"
property
"
})])
}
;
})]);
};
StorageGetWithAttachment
.
prototype
.
get
=
function
(
options
)
{
deepEqual
(
options
,
{
"
_id
"
:
"
foo
"
},
"
Get foo
"
);
...
...
@@ -269,12 +269,12 @@
deepEqual
(
param
,
{
"
_id
"
:
"
foo
"
,
"
_attachment
"
:
"
jio_attachment/YmFy/YmFyMg==
"
},
"
getAttachment 200 called
"
);
return
{
data
:
blob
}
;
return
blob
;
};
jio
.
getAttachment
({
"
_id
"
:
"
bar
"
,
"
_attachment
"
:
"
bar2
"
})
.
then
(
function
(
result
)
{
equal
(
result
.
data
,
blob
);
equal
(
result
,
blob
);
})
.
fail
(
function
(
error
)
{
ok
(
false
,
error
);
...
...
test/jio.storage/drivetojiomapping.tests.js
View file @
f4a45ae1
...
...
@@ -145,7 +145,7 @@
deepEqual
(
options
,
{
"
_id
"
:
"
/.jio_documents/
"
,
"
_attachment
"
:
"
bar.json
"
},
"
getAttachment
"
);
return
{
data
:
new
Blob
([
JSON
.
stringify
({
title
:
"
foo
"
})])}
;
return
new
Blob
([
JSON
.
stringify
({
title
:
"
foo
"
})])
;
};
StorageGetOnlyDocument
.
prototype
.
get
=
function
(
options
)
{
deepEqual
(
options
,
{
"
_id
"
:
"
/
"
},
"
Get document
"
);
...
...
@@ -189,7 +189,7 @@
deepEqual
(
options
,
{
"
_id
"
:
"
/.jio_documents/
"
,
"
_attachment
"
:
"
bar.json
"
},
"
getAttachment
"
);
return
{
data
:
new
Blob
([
JSON
.
stringify
({
title
:
"
foo
"
})])}
;
return
new
Blob
([
JSON
.
stringify
({
title
:
"
foo
"
})])
;
};
StorageGetBoth
.
prototype
.
get
=
function
(
options
)
{
deepEqual
(
options
,
{
"
_id
"
:
"
/
"
},
"
Get document
"
);
...
...
@@ -575,12 +575,12 @@
deepEqual
(
param
,
{
"
_id
"
:
"
/
"
,
"
_attachment
"
:
"
bar
"
},
"
getAttachment 200 called
"
);
return
{
data
:
blob
}
;
return
blob
;
};
jio
.
getAttachment
({
"
_id
"
:
"
bar
"
,
"
_attachment
"
:
"
enclosure
"
})
.
then
(
function
(
result
)
{
equal
(
result
.
data
,
blob
);
equal
(
result
,
blob
);
})
.
fail
(
function
(
error
)
{
ok
(
false
,
error
);
...
...
test/jio.storage/erp5storage.tests.js
View file @
f4a45ae1
...
...
@@ -299,9 +299,9 @@
equal
(
server
.
requests
[
1
].
requestBody
,
undefined
);
equal
(
server
.
requests
[
1
].
withCredentials
,
true
);
ok
(
result
.
data
instanceof
Blob
,
"
Data is Blob
"
);
deepEqual
(
result
.
data
.
type
,
"
application/hal+json
"
,
"
Check mimetype
"
);
return
jIO
.
util
.
readBlobAsText
(
result
.
data
);
ok
(
result
instanceof
Blob
,
"
Data is Blob
"
);
deepEqual
(
result
.
type
,
"
application/hal+json
"
,
"
Check mimetype
"
);
return
jIO
.
util
.
readBlobAsText
(
result
);
})
.
then
(
function
(
result
)
{
var
expected
=
JSON
.
parse
(
document_hateoas
);
...
...
@@ -359,9 +359,9 @@
equal
(
server
.
requests
[
1
].
requestBody
,
undefined
);
equal
(
server
.
requests
[
1
].
withCredentials
,
true
);
ok
(
result
.
data
instanceof
Blob
,
"
Data is Blob
"
);
deepEqual
(
result
.
data
.
type
,
"
application/hal+json
"
,
"
Check mimetype
"
);
return
jIO
.
util
.
readBlobAsText
(
result
.
data
);
ok
(
result
instanceof
Blob
,
"
Data is Blob
"
);
deepEqual
(
result
.
type
,
"
application/hal+json
"
,
"
Check mimetype
"
);
return
jIO
.
util
.
readBlobAsText
(
result
);
})
.
then
(
function
(
result
)
{
var
expected
=
JSON
.
parse
(
document_hateoas
);
...
...
@@ -409,9 +409,9 @@
equal
(
server
.
requests
[
0
].
requestBody
,
undefined
);
equal
(
server
.
requests
[
0
].
withCredentials
,
true
);
ok
(
result
.
data
instanceof
Blob
,
"
Data is Blob
"
);
deepEqual
(
result
.
data
.
type
,
"
application/json
"
,
"
Check mimetype
"
);
return
jIO
.
util
.
readBlobAsText
(
result
.
data
);
ok
(
result
instanceof
Blob
,
"
Data is Blob
"
);
deepEqual
(
result
.
type
,
"
application/json
"
,
"
Check mimetype
"
);
return
jIO
.
util
.
readBlobAsText
(
result
);
})
.
then
(
function
(
result
)
{
var
expected
=
JSON
.
parse
(
document_hateoas
);
...
...
test/jio.storage/indexeddbstorage.tests.js
View file @
f4a45ae1
...
...
@@ -986,8 +986,8 @@
"
_attachment
"
:
attachment
});
})
.
then
(
function
(
result
)
{
ok
(
result
.
data
instanceof
Blob
,
"
Data is Blob
"
);
return
jIO
.
util
.
readBlobAsText
(
result
.
data
);
ok
(
result
instanceof
Blob
,
"
Data is Blob
"
);
return
jIO
.
util
.
readBlobAsText
(
result
);
})
.
then
(
function
(
result
)
{
equal
(
result
.
target
.
result
,
big_string
,
...
...
@@ -1022,8 +1022,8 @@
"
_start
"
:
1999995
,
"
_end
"
:
2000005
});
})
.
then
(
function
(
result
)
{
ok
(
result
.
data
instanceof
Blob
,
"
Data is Blob
"
);
return
jIO
.
util
.
readBlobAsText
(
result
.
data
);
ok
(
result
instanceof
Blob
,
"
Data is Blob
"
);
return
jIO
.
util
.
readBlobAsText
(
result
);
})
.
then
(
function
(
result
)
{
var
expected
=
"
aaaaaaaaaa
"
;
...
...
test/jio.storage/localstorage.tests.js
View file @
f4a45ae1
...
...
@@ -180,11 +180,11 @@
"
_attachment
"
:
attachment
})
.
then
(
function
(
result
)
{
ok
(
result
.
data
instanceof
Blob
,
"
Data is Blob
"
);
deepEqual
(
result
.
data
.
type
,
"
text/plain;charset=utf-8
"
,
ok
(
result
instanceof
Blob
,
"
Data is Blob
"
);
deepEqual
(
result
.
type
,
"
text/plain;charset=utf-8
"
,
"
Check mimetype
"
);
return
jIO
.
util
.
readBlobAsText
(
result
.
data
);
return
jIO
.
util
.
readBlobAsText
(
result
);
})
.
then
(
function
(
result
)
{
equal
(
result
.
target
.
result
,
value
,
"
Attachment correctly fetched
"
);
...
...
@@ -222,8 +222,8 @@
"
_attachment
"
:
attachment
})
.
then
(
function
(
result
)
{
ok
(
result
.
data
instanceof
Blob
,
"
Data is Blob
"
);
return
jIO
.
util
.
readBlobAsDataURL
(
result
.
data
);
ok
(
result
instanceof
Blob
,
"
Data is Blob
"
);
return
jIO
.
util
.
readBlobAsDataURL
(
result
);
})
.
then
(
function
(
result
)
{
equal
(
result
.
target
.
result
,
data_url
,
"
Attachment correctly fetched
"
);
...
...
test/jio.storage/memorystorage.tests.js
View file @
f4a45ae1
...
...
@@ -320,8 +320,8 @@
"
_attachment
"
:
attachment
})
.
then
(
function
(
result
)
{
ok
(
result
.
data
instanceof
Blob
,
"
Data is Blob
"
);
equal
(
result
.
data
,
blob
);
ok
(
result
instanceof
Blob
,
"
Data is Blob
"
);
equal
(
result
,
blob
);
})
.
fail
(
function
(
error
)
{
ok
(
false
,
error
);
...
...
test/jio.storage/querystorage.tests.js
View file @
f4a45ae1
...
...
@@ -185,12 +185,12 @@
Storage200
.
prototype
.
getAttachment
=
function
(
param
)
{
deepEqual
(
param
,
{
"
_id
"
:
"
bar
"
,
"
_attachment
"
:
"
foo
"
},
"
getAttachment 200 called
"
);
return
{
data
:
blob
}
;
return
blob
;
};
jio
.
getAttachment
({
"
_id
"
:
"
bar
"
,
"
_attachment
"
:
"
foo
"
})
.
then
(
function
(
result
)
{
equal
(
result
.
data
,
blob
);
equal
(
result
,
blob
);
})
.
fail
(
function
(
error
)
{
ok
(
false
,
error
);
...
...
test/jio.storage/uuidstorage.tests.js
View file @
f4a45ae1
...
...
@@ -199,12 +199,12 @@
Storage200
.
prototype
.
getAttachment
=
function
(
param
)
{
deepEqual
(
param
,
{
"
_id
"
:
"
bar
"
,
"
_attachment
"
:
"
foo
"
},
"
getAttachment 200 called
"
);
return
{
data
:
blob
}
;
return
blob
;
};
jio
.
getAttachment
({
"
_id
"
:
"
bar
"
,
"
_attachment
"
:
"
foo
"
})
.
then
(
function
(
result
)
{
equal
(
result
.
data
,
blob
);
equal
(
result
,
blob
);
})
.
fail
(
function
(
error
)
{
ok
(
false
,
error
);
...
...
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