![]() According to MDN, I should be using the FileReader method readAsText() as it has better browser support. text() doesn't work in some browsers, including Safari. I still don’t fully understand what blobs are, but it worked, so it’s all good.īut actually it’s not all good because. ![]() I followed that pattern and boom! It worked. Seems like I had the makings of what I wanted. Perfect! Just what I wanted, the textual contents of the file. text() that returns a promise that resolves to a string. But what the hell is a blob and how do I use it?Īfter doing some research, I realized blobs have a method named. But I wanted to get the contents of the file, how would I do that? “Oh hey, look at that little key named fileBlob of type Blob.I bet that’s what I’m looking for,” I thought to myself. There’s some general information there about the file itself. When you try to download a file from Dropbox using the JS SDK, you’ll use filesDownload which will give you back a representation of the file that looks something like this: If you’re working with non-textual files in Dropbox, this post might not be what you’re looking for. Note: it’s worth mentioning that, in this post, I’m specifically talking about downloading and uploading textual JSON files to Dropbox. So let’s talk about Blobs and Files in JavaScript, something I knew nothing about before this article and now know slightly more than nothing about. A lot which I want to write down because when I was searching for solutions to my problems I didn’t find a lot of helpful articles on the internet from people who had similar questions. That’s ok though, it’s making me learn a lot. ![]() Don’t get me wrong, they definitely have thorough, extensive documentation-the docs just aren’t exactly beginner friendly. I have to admit, using the Dropbox JavaScript SDK documentation hasn’t been the easiest thing. ![]() If I screw something up, I just open the folder on my Mac and delete files, rename them, open and edit them, etc. Just store my app data as textual JSON files in a Dropbox folder based on some naming schema. Lots of smart folks at Dropbox, so their API and services are fast and dependable. As in, I already pay for a Dropbox account. Because I don’t want to-and don’t really know how to-deal with setting up a database as a storage layer, I’ve decided to try using Dropbox. I’ve been toying around with an idea for a new project.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
February 2023
Categories |