Using Tizen 4.0 NOT 5.0
I want to be able to write image blob to directory and then retrieving the saved image to be displayed,
this is what i have so far it is not working:
for reading:
tizen.filesystem.resolve(IMAGE_DIRECTORY_PATH + "/" + slide.MediaFileName, function (dir) {
dir.openStream("r", function (fs) {
var mediaByteArray = fs.readBytes(1000000);
let uint8Array = new Uint8Array(mediaByteArray);
let mediaBlob = new Blob([uint8Array]);
var mediaUrl = URL.createObjectURL(mediaBlob);
console.log(mediaUrl);
});
}, errorCallback, "r"
);
for writing:
var xhr = new XMLHttpRequest();
xhr.open("GET", slide.MediaFileFullName, true);
xhr.setRequestHeader("Content-Type", "application/json");
xhr.responseType = "blob";
xhr.onload = function () {
if (xhr.readyState === 4 && xhr.status === 200) {
var imageBlob = xhr.response;
tizen.filesystem.resolve(
IMAGE_DIRECTORY_PATH,
function (dir) {
imagesDir = dir;
dir.listFiles(function (images) {
for (var i = 0; i < images.length; i++) { console.log("File name is " + images[i].name); }
var imageFile = imagesDir.createFile(slide.MediaFileName);
imageFile.openStream(
"w",
function (fs) {
fs.write(imageBlob, "UTF-8");
fs.close();
},
function (e) {
console.log("Error Writing Image: " + e.message);
},
"UTF-8"
);
}, onerror);
},
function (e) { console.log("Error: " + e.message); },
"w"
);