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
Alexandra Rogova
jio
Commits
902f54fe
Commit
902f54fe
authored
Jan 23, 2015
by
Romain Courteaud
🐸
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Store blob as text in localstorage.
parent
4a176103
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
12 deletions
+4
-12
src/jio.storage/localstorage.js
src/jio.storage/localstorage.js
+4
-12
No files found.
src/jio.storage/localstorage.js
View file @
902f54fe
...
...
@@ -69,20 +69,12 @@
LocalStorage
.
prototype
.
getAttachment
=
function
(
param
)
{
restrictDocumentId
(
param
.
_id
);
var
binarystring
=
localStorage
.
getItem
(
param
.
_attachment
),
i
,
uint8array
;
var
textstring
=
localStorage
.
getItem
(
param
.
_attachment
);
if
(
binary
string
===
null
)
{
if
(
text
string
===
null
)
{
throw
new
jIO
.
util
.
jIOError
(
"
Cannot find attachment
"
,
404
);
}
uint8array
=
new
Uint8Array
(
binarystring
.
length
);
for
(
i
=
0
;
i
<
binarystring
.
length
;
i
+=
1
)
{
uint8array
[
i
]
=
binarystring
.
charCodeAt
(
i
);
// mask `& 0xFF` not necessary
}
return
new
Blob
([
uint8array
.
buffer
]);
return
new
Blob
([
textstring
]);
};
LocalStorage
.
prototype
.
putAttachment
=
function
(
param
)
{
...
...
@@ -92,7 +84,7 @@
// download data
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
return
jIO
.
util
.
readBlobAs
BinaryString
(
param
.
_blob
);
return
jIO
.
util
.
readBlobAs
Text
(
param
.
_blob
);
})
.
push
(
function
(
e
)
{
localStorage
.
setItem
(
param
.
_attachment
,
e
.
target
.
result
);
...
...
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