Create image file (Base64 to blob) using Google Appscript -
i have created function using google appscript convert base64 blob , use blob create file google drive folder. however, file created no image displaying.
here's code:
function base64toblob() { var currentfolder = driveapp.getfolderbyid("--my google drive id--"); var base64 = "ivborw0kggoaaaansuheugaaacaaaaagcayaaabzenr0aaago0leqvr42rww+u9vrxthd9uzqacfiqbfm6jnlyhlw6mgnubw3mbyf9jitwlqo9yqlsi+wwnxkqqprqhlb2wtioilcs/iwqrijkjuwk2tppo3fhvm3qu3lmzxiysfzj2zm3o+c86ceraaeoc/c+9q+m5bglxrwghecujbjik5ywpkrv9zwps1ppuop2ebdfpk1etq93ijrv8dkbdf0piyezbcdkqftf1j2gxhbp3lwah5vhffj+ygp8sjmz2jbejbjik5yubyuvvtmjesymuhfpp0atyq/lijo63wonbceqkksl/mstz6tvwool+ispmuaix8wilfngjplgfxncegzr7lfsuq0kjqnxcsmzsb8jg8d6cjuph7knxrgappxbrvvhomc7bi5f0/5jmj/pfqgdm/tf3f4oqzr3g8/vpe3sak3iikqxb/keeabzfr5wo+lpej6antbvjogunqllwxdrgbp7qnif2ea461oic/ayoqh69hwqmlyq8t4n5jui01emjqwuidbbds//v84qnpkqbhrguqafufsejrlx8on9kg8sa9jofjbbbbyx0/rf0jrncq4o3monexgcwpp0crwy333cs4nj/r7aofwca4uwu4+sazi6/nq5xgilzgve+a3tit4zf5+5o5crpnia/reylcv9y1fi33p6dg/kyejytxwb+kgjnjajq25likmsnptebefuieowqpiordjhyqk1jjgp2vhpqmnxhajyhpnkno60ur5z/9zgqcbzieef43p5iwijseeaftkiiye5mas3nbalj4zsll3xhlz3wofhyocfhpemq1umppwclecwy3qb8sjjv+jkhatowac25fuqxw5oen78ex93kgjc82irtbb78ujbiqqekedrhgszycrckvdq1e1zpv/ki4ir1tter254dcdf4o6l6guctjufzwuramhdcboptwbq7vo0vriauxwow+abt2emhqnk66wfkdtih95ivltwlgn6ybvxctksohcrd0dqgkyhpteefcuc7rvziusnu+rgxfwhq8migmngdmtgilflxfbhgap+jkqycmdyciuu6lcq/paz8eww0f8pvsl5elksbo3nsyhn8kc/4srj3/i/g6wtemz5t2rsdho9bqs8dkjkikkyzgvhgv612ognzptoo8jkgf+wzvvdyzupxokgwpcnauak7cmybvdzxxide1hdodvjjyymulonwjpjbomy6likwwfti86u2uwj1io1sfksbpyaqogvtexsvevq9evelu3s9ex7t4osgxulylq+i1l4ysezlt+ddsa6iarvgqiw8wgjbkwsebzogwp3gzpc/b7s/nnechesqexybsp80cwunfyagout1uuymhddlopxshl6vso0fkm/aw2ezecfcjrxely6w6h+gw+/i+yxmj09dq0oa7yofgsl4icjsl2alyxkzqypswigphdat8i+ecrd28zkks4fs8/i5hink9tz/ky87nbqhtrdrlcbvymhpgz6b14mc30mcnkosfxfigo/h783gotiuakcgi8raw4xeymgsrvc/zrz1emqrfdroowgr7y2krkyyi3bn7we+a+bvffgtnqr5eo+nmkhh5oy/yjm4ca+ktscftviiireyzcvel8fu8vy7eha16c9qlmah4j+mylwmwmfozkypzi2gfykxebgy2480sfhsubye0hjuiap0olevlcbzwhiovolxbuc/gv4o3q2u2dywplsj9wxluxbgpf06rhn3sbb+glowd46gsdgn0etsibektkzy+dosiojdrmvniooerhfi9br259qg9oego7fzhudka//s/oubzshecrtqfg4/mneeurhyeo/kuolmvultxhl35y1gbao1sk5wpfwcyigwwctnni87zm9fzyhlznof2pefuhrifzw11broa00vk8kn76/ehgx3fytci5choza7jfgqfqclcdela7b1oy3vew54tbifyiusovzvq/p0ikj7tzg1ybnqfghwwkgjpuvff9/cuqot9zxmouguc0vxggka9a3j2vl8bmtwgwiuoszmhippj2kgs8xo7xjzksf9cwyw/hsxnymvbpaidmueh2nqoaaqylenkilpti/apro4ks6kabkwaaaaasuvork5cyii="; var decoded = utilities.base64decode(base64); var blob = utilities.newblob(decoded); logger.log(blob); // returns blob currentfolder.createfile("a blob title", blob, "image/png"); }
thanks in advance.
var blob = utilities.newblob(decoded, mimetype.jpeg, "nameofimage"); currentfolder.createfile(blob);
give go, did similar. helps :)
Comments
Post a Comment