nop i don't have any GitHub and here is easy and better option using http module
which uses base64 and save its in folder
//upload function
uploadImage (data : any) {
return this.http.post(`http://${serverIP}/api/v2/files/images/`,
JSON.stringify({resource : [data] }))
.map((data) => {
return data;
});
}
onChange(files : any){
// calling upload function
let base64 = this.getBase64(files[0])
let src = base64.replace("data:image/jpeg;base64,",'');
let name = `whateverName.jpg`
let data = {
"name": name,
"type": "file",
"is_base64": true,
"content": src
}
this.uploadImage(data).subscribe(
data => console.log(data),
error => console.log(error)
)
}
//convert to base64
getBase64(file){
var reader = new FileReader();
reader.addEventListener("load", function (event ) {
return event.target.result;
}, false);
if (file) {
reader.readAsDataURL(file);
}
}
<input type="file" #image onchange="onChange(image.files)" />
this will save whateverName.jpg in /files/images/
source http://wiki.dreamfactory.com/DreamFactory/Tutorials/Uploading_File
hope this help