Commit 438f3a83 authored by svilayphiou's avatar svilayphiou
Browse files

read blob text + svg

parent 08d3c006
......@@ -61,19 +61,24 @@
var blob = this_url.searchParams.get("blob");
if (blob){
var blob_url = "https://gitlab.constantvzw.org/api/v4/projects/456/repository/blobs/" + blob + "/raw";
console.log(blob_url);
//README = file.id;
console.log(blob_url);
const blob_elt = document.querySelector('#blob');
fetch(blob_url)
.then((resp) => resp.blob())
.then(function(data){
console.log(data);
var mime = data["type"];
if(mime == "image/png" | mime == "image/jpg" | mime == "image/gif") {
let img = document.createElement('img');
img.src = blob_url;
blob_elt.appendChild(img);
} else {
blob_elt.innerHTML = 'data';
} else if (mime == "text/plain" | mime == "image/svg+xml") {
var reader = new FileReader();
reader.onloadend=function(){
console.log(reader.result);
blob_elt.innerHTML = reader.result;
};
reader.readAsText(data);
}
})
}
......@@ -103,20 +108,20 @@
// ICEBERG
if (file.name == "iceberg"){
iceberg = fil4.id;
const iceberg_elt = document.querySelector('#iceberg');
const iceberg_url = "https://gitlab.constantvzw.org/api/v4/projects/456/repository/tree/?path=iceberg";
fetch(iceberg_url)
.then((resp) => resp.json())
.then(function(data){
return data.map(function(iceberg) {
let img = document.createElement('img');
img.src = "https://gitlab.constantvzw.org/osp/work.contour/raw/master/" + iceberg.path;
iceberg_elt.appendChild(img);
});
})
}
//if (file.name == "iceberg"){
// iceberg = fil4.id;
// const iceberg_elt = document.querySelector('#iceberg');
// const iceberg_url = "https://gitlab.constantvzw.org/api/v4/projects/456/repository/tree/?path=iceberg";
// fetch(iceberg_url)
// .then((resp) => resp.json())
// .then(function(data){
// return data.map(function(iceberg) {
// let img = document.createElement('img');
// img.src = "https://gitlab.constantvzw.org/osp/work.contour/raw/master/" + iceberg.path;
// iceberg_elt.appendChild(img);
// });
// })
//}
})
})
.catch(function(error) {
......
Supports Markdown
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