Skip to content

Instantly share code, notes, and snippets.

View devmariodiaz's full-sized avatar
🏠
Working from home

Mario Diaz Peñaloza devmariodiaz

🏠
Working from home
  • Spain
  • 18:23 (UTC +02:00)
View GitHub Profile
import { Component } from "@angular/core";
@Component({
selector: "app-root",
templateUrl: "./app.component.html",
styleUrls: ["./app.component.css"]
})
export class AppComponent {
title = "CodeSandbox";
const base64 = '...';
const imageName = 'name.png';
const imageBlob = this.dataURItoBlob(base64);
const imageFile = new File([imageBlob], imageName, { type: 'image/png' });
dataURItoBlob(dataURI) {
const byteString = window.atob(dataURI);
const arrayBuffer = new ArrayBuffer(byteString.length);
const int8Array = new Uint8Array(arrayBuffer);
for (let i = 0; i < byteString.length; i++) {
const getUsuarioByID = (id, callback) => {
const usuario = {
id,
nombre: 'Mario'
}
setTimeout(() => {
callback(usuario);
}, 1500);
}