const base64 = {
    fileType: {
        image: {
            png: 'image/png',
            jpg: 'image/jpeg',
            gif: 'image/gif',
            svg: 'image/svg+xml',
            ico: 'image/x-icon',
            bmp: 'image/bmp',
        },
        document: {
            xlsx: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
            xls: 'application/vnd.ms-excel',
            doc: 'application/msword',
            docx: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
            pdf: 'application/pdf',
            ppt: 'application/vnd.ms-powerpoint',
            pptx: 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
            txt: 'text/plain',
        }
    },
    download(data, fileType, name) {
        const url = 'data:' + fileType + ';base64,' + data;
        const a = document.createElement('a');
        a.href = url;
        a.setAttribute('download', name);
        a.click();
    }
}

export default base64