Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Sven Franck
jio
Commits
974cac47
Commit
974cac47
authored
Dec 24, 2012
by
Tristan Cavelier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
localstorage.js putAttachment method redesigned
parent
0747228c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
8 deletions
+36
-8
src/jio.storage/localstorage.js
src/jio.storage/localstorage.js
+36
-8
No files found.
src/jio.storage/localstorage.js
View file @
974cac47
...
@@ -130,17 +130,45 @@ var newLocalStorage = function (spec, my) {
...
@@ -130,17 +130,45 @@ var newLocalStorage = function (spec, my) {
/**
/**
* Add an attachment to a document
* Add an attachment to a document
* @method
_
putAttachment
* @method putAttachment
* @param {object} command The JIO command
* @param {object} command The JIO command
*
* Available options:
* - {boolean} conflicts Add a conflicts object to the response
* - {boolean} revs Add the revisions history of the document
* - {boolean} revs_info Add revisions informations
*/
*/
that
.
_
putAttachment
=
function
(
command
)
{
that
.
putAttachment
=
function
(
command
)
{
setTimeout
(
function
()
{
setTimeout
(
function
()
{
that
.
success
(
priv
.
setDocument
(
command
,
'
put
'
);
var
doc
;
doc
=
localstorage
.
getItem
(
priv
.
localpath
+
"
/
"
+
command
.
getDocId
());
if
(
typeof
doc
===
"
undefined
"
)
{
// the document does not exists
that
.
error
({
"
status
"
:
404
,
"
statusText
"
:
"
Not Found
"
,
"
error
"
:
"
not_found
"
,
"
message
"
:
"
Impossible to add attachment
"
,
"
reason
"
:
"
Document not found
"
});
return
;
}
else
{
// the document already exists
doc
[
"
_attachments
"
]
=
doc
[
"
_attachments
"
]
||
{};
doc
[
"
_attachments
"
][
command
.
getAttachmentId
()]
=
{
"
content_type
"
:
command
.
getAttachmentMimeType
(),
"
digest
"
:
"
md5-
"
+
command
.
md5SumAttachmentData
(),
"
length
"
:
command
.
getAttachmentLength
()
};
}
// upload data
localstorage
.
setItem
(
priv
.
localpath
+
"
/
"
+
command
.
getAttachmentId
(),
command
.
getAttachmentData
());
// write document
localstorage
.
setItem
(
priv
.
localpath
+
"
/
"
+
command
.
getDocId
(),
doc
);
that
.
success
({
"
ok
"
:
true
,
"
_id
"
:
command
.
getDocId
()
+
"
/
"
+
command
.
getAttachmentId
()
});
});
});
};
};
...
...
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