Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialammarkhan
Front End Web Development Techdegree Student 21,661 PointsWhat is a blob?
I am trying to convert a base64 code into a pdf. The way I have seen on stackoverflow, they said to convert into a blob and then do whatever you want. I do not know what blob is and why we need it to convert a base64 into a file? The data is a object with key value. I tried tgat base64 in a online converter and it gave me a pdf but unable to understand how do I do it?
1 Answer
Steven Parker
229,644 PointsA "Blob" is an object that represents immutable, raw data, that isn't necessarily in a JavaScript-native format. For more information, see the MDN page.
Once you've decoded the data, you probably want to write it into a disk file. Assuming you're working in node.js, the fs module might be useful for that. The conversion itself might be done using the b64-to-blob package.
ammarkhan
Front End Web Development Techdegree Student 21,661 Pointsammarkhan
Front End Web Development Techdegree Student 21,661 PointsIt is hard to understand. What if I got a file, say a ready to go PDF and want to download on button click, do I need blob to save file to disk as it is already a file, what steps are involved?
Steven Parker
229,644 PointsSteven Parker
229,644 PointsThe File interface is based on Blob, so when using it you should not need a separate Blob object.