Commit 37761727 authored by Tristan Cavelier's avatar Tristan Cavelier

example.html updated

parent 571de20f
...@@ -16,11 +16,10 @@ var log = function (o) { ...@@ -16,11 +16,10 @@ var log = function (o) {
</script> </script>
<div id="log"> <div id="log">
</div> </div>
<script type="text/javascript" src="../lib/md5/md5.js"></script> <script src="../src/sha256.amd.js"></script>
<script type="text/javascript" src="../jio.js"></script> <script src="../jio.js"></script>
<script type="text/javascript" src="../src/jio.storage/localstorage.js"> <script src="../complex_queries.js"></script>
</script> <script src="../src/jio.storage/localstorage.js"></script>
<script type="text/javascript" src="../lib/jquery/jquery.min.js"></script>
<script type="text/javascript"> <script type="text/javascript">
<!-- <!--
var jio_instance = null; var jio_instance = null;
...@@ -28,7 +27,7 @@ var jio_instance = null; ...@@ -28,7 +27,7 @@ var jio_instance = null;
log('Welcome to the jIO example.html!') log('Welcome to the jIO example.html!')
log('-> Create jIO instance'); log('-> Create jIO instance');
jio_instance = jIO.newJio({ jio_instance = jIO.createJIO({
"type": 'local', "type": 'local',
"username": 'jIOtest', "username": 'jIOtest',
"applicationname": 'example' "applicationname": 'example'
...@@ -43,52 +42,67 @@ jio_instance.post({ ...@@ -43,52 +42,67 @@ jio_instance.post({
"codec": 'vorbis', "codec": 'vorbis',
"language": 'en', "language": 'en',
"description": 'Image compilation' "description": 'Image compilation'
}, function (response) { }).then(function () {
log('-> put "thumbnail" attachment to localStorage'); log('-> put "thumbnail" attachment to localStorage');
jio_instance.putAttachment({ return jio_instance.putAttachment({
"_id": "video", "_id": "video",
"_attachment": "thumb.jpg", "_attachment": "thumb.jpg",
"_data": "BASE64DATA", "_data": "This is the thumbnail content",
"_mimetype": 'image/jpeg' "_mimetype": 'image/jpeg'
}, function (response) { });
}).then(function () {
log('-> put "video" attachment to localStorage'); log('-> put "video" attachment to localStorage');
jio_instance.putAttachment({ return jio_instance.putAttachment({
"_id":"video", "_id":"video",
"_attachment": "myvideo.ogg", "_attachment": "myvideo.ogg",
"_data": "BASE64DATATOO", "_data": new Blob(["This is the video content"], {"type": "video/ogg"})
"_mimetype":'video/ogg'
}, function (val) {
log('Done! Refresh the page to see get and remove command.');
}, function (err) {
log('Error! '+ err.reason);
}); });
}, function (err) { }).then(function (response) {
log('Error! ' + err.reason);
}); log('Done! Refresh the page to see get and remove command.');
}, function (err) { }, function (err) {
log('Error! ' + err.reason); log('Error! ' + err.statusText + ": " + err.reason + ", " + err.message);
log('-> get "video" document metadata from localStorage'); log('-> get "video" document metadata from localStorage');
jio_instance.get('video', function (val) { jio_instance.get({
"_id": "video"
}).then(function (response) {
log('Title is: "' + response.data.title + '"');
log('-> get "video" attachment content');
return jio_instance.getAttachment({
"_id": "video",
"_attachment": "myvideo.ogg"
});
}).then(function (response) {
log('Title is: "' + val["title"] + '"'); return jIO.util.blobAsBinaryString(response.data);
}).then(function (binary_string) {
log('Video content is: ' + binary_string);
log('-> remove "video" document from localStorage'); log('-> remove "video" document from localStorage');
jio_instance.remove({"_id":'video'}, function (val) { return jio_instance.remove({"_id":'video'});
}).then(function (response) {
log('Done! Refresh the page to see post and putAttachment command.'); log('Done! Refresh the page to see post and putAttachment command.');
}, function (err) {
log('Error! ' + err.reason);
});
}, function (err) { }, function (err) {
log('Error! ' + err.reason);
log('Error! ' + err.statusText + ": " + err.reason + ", " + err.message);
}); });
}); });
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment