Тёмный

generate downloadable files in the browser using Blob and URL API 

SpinSpire
Подписаться 1,3 тыс.
Просмотров 66 тыс.
50% 1

Shows how to create CSV, TXT, PDF, ICS/iCal, etc files right within the browser without ever hitting server-side. Uses the Blob API to build files in the browser and the URL API to create object URLs from them to make them downloadable. The whole thing is as simple as ...
const a = document.getElementById("a1");
const blob = new Blob(["your data"]);
a.href = URL.createObjectURL(blob);
For questions, post a comment. For business inquiries, email info@spinspire.com.

Опубликовано:

 

27 июн 2020

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 68   
@ade5324
@ade5324 3 года назад
short and simple tutorial, but just what i needed for my project. this is awesome thank you!!!
@shubhamh7451
@shubhamh7451 3 года назад
Just want to thank you for the amount of dopamine rushed through me when I finally found the solution to the problem bugging me since a long time
@himabindu442
@himabindu442 3 года назад
This gives a good understanding of Blob API.Thanks!!
@asimgiri4269
@asimgiri4269 3 года назад
Such an easy explanation. Thank You for sharing
@pedromoreira1311
@pedromoreira1311 Год назад
Nice class! Thank you!
@freelancefabian3946
@freelancefabian3946 3 года назад
Great example, ran into this issue the other day and used the same solution.
@michaelcasile1036
@michaelcasile1036 2 месяца назад
Very helpful. I will be trying to use this with pdfkit which can stream to a blob and hopefully this will help me get that blob to download as a PDF. Thanks again.
@rahilahmad4318
@rahilahmad4318 4 года назад
Thanks, Awesome content.
@ekkysukmawati9696
@ekkysukmawati9696 2 года назад
Awesome Thank you Sir!
@gaganbedi4332
@gaganbedi4332 Год назад
very well explained sir. God Bless You.
@officewires518
@officewires518 2 года назад
Very helpful thank you so much
@afridim1813
@afridim1813 Год назад
Awesome. Good tutorial
@mishagakman3966
@mishagakman3966 2 года назад
Thank you !
@henoknigatu7121
@henoknigatu7121 12 дней назад
very helpfull thank you👏
@pikimell
@pikimell Год назад
Thank you very much ❤️🔥
@ManjunathManja1227
@ManjunathManja1227 3 года назад
Nice!
@joeporsche1767
@joeporsche1767 3 года назад
Very good content. Cheer
@carminone
@carminone 2 года назад
Remarkable!
@Yoko-0x0
@Yoko-0x0 3 года назад
when applying this to the mp4 video link, as it would do for the video buffer. because the whole video is being downloaded so that it can start playing
@TriWaZe
@TriWaZe 2 года назад
I have a blob file generated from my webcam but I'm trying to figure out how to send that mp4 file to my server. Think you could help?
@professorbharathidasan8027
@professorbharathidasan8027 Год назад
Super
@nbietz
@nbietz Год назад
Can you convert a base64 encoded image (say from canvasElement.toDataURL('image/jpeg')) to a Blob or File in the browser for the purpose of uploading to some storage API?
@yogeshbansal4311
@yogeshbansal4311 3 года назад
Hello sir, I would like to know if my file is greater than 12 mb and service returning result in blob and it is taking time on server how can I tell user to wait or any way to reduce the service response time?
@CyberTechBits
@CyberTechBits 3 года назад
@SpinSpire That's a very nice tutorial. I am writing a quoting tool and ran into a roadblock. I am able to save, client side, the quotes in JSON format using blob... very easy and nice so thanks for that pointer since i was using file reader previously. Blob is cleaner IMO. However, I ran into a problem and curious if you can help? I need to be able to upload those same JSON files into the web application client side. I cannot find anywhere any information that will allow a user to select the JSON file locally in order to import or upload it to the application. Any pointers?
@SpinSpire
@SpinSpire 3 года назад
Glad that you found it useful. It's actually pretty easy. Please email me at info@SpinSpire.com so I can understand your requirements better.
@tobias9164
@tobias9164 Месяц назад
I don't get it. Where so you start with all this? I'm a beginner and I would like to know what the whole screen is you work in in the first place...
@fashiondiaries17
@fashiondiaries17 2 года назад
Sir this video was usefull but I have a question that I have made the Google spread sheet in my computer i have to give this website to anyone is this spread sheet will open automatically? Or in other computer like we did we have to make a excel sheet?
@vinny1010
@vinny1010 Год назад
Any thoughts on downloading a video that is a Blob URL?
@prajakta.gandhi
@prajakta.gandhi 2 года назад
Sir, can you provide me code where We can export chart, table and html data together into single .doc file one after the next , in javascript or angular.
@philiperiskallaleal6010
@philiperiskallaleal6010 Год назад
Dear Sir, I would like to know how one may apply your approach for a binary streames file, let's say an Excel file that was generates from the Server. I thank you for your time. Sincerely,
@raiyansarker1698
@raiyansarker1698 3 года назад
How to make that blob URL unvisitable or downloadable like used in netflix or udemy? Please make a video about this. Couldn't find anything better related to this problem!
@thrinethrar3026
@thrinethrar3026 3 года назад
I wanted to download zip file in browser which I received from post url containing no body. Please help to create blob for such content. Zip file is a stream that has two files inside it.
@Heffsta02
@Heffsta02 3 года назад
stuk.github.io/jszip/ JsZip framework has some good options for zipping on the client side.
@himabindu442
@himabindu442 3 года назад
How can we create a zip file insted of single file, do we have an API for the same or do we need to use zip library. Please suggest
@SpinSpire
@SpinSpire 3 года назад
Yeah, you'd have to use the zip library to create and serve zip files.
@emilytan7677
@emilytan7677 3 года назад
Please help how if i want to include this 'a1' blob url in this form. I need src to use the blob url. The bottom code does not work.
@boryziin
@boryziin 3 года назад
did you find out how to do this? if so, can you tell me how you did it, please?
@BrainOfJS
@BrainOfJS 2 года назад
So Excuse me sir you can download video with this method or not
@ad4m-10
@ad4m-10 3 года назад
Will this work on ios Safari and ios chrome ?
@SpinSpire
@SpinSpire 3 года назад
I'm fairly confident that it should. The URL and Blob API's are quite universal and well supported by all modern browsers.
@souvikkumarpaul4282
@souvikkumarpaul4282 2 года назад
how to download get response from MySQL database as a PDF file?
@azadehrazavi1651
@azadehrazavi1651 2 года назад
so helpful thank you .. does it work also for images ?
@SpinSpire
@SpinSpire 2 года назад
Yes. It does. It works for any kind of file you can construct in browser JS, stuff it into a Blob, and then provide a link to that Blob URL.
@hoshi411
@hoshi411 Год назад
I wanted to see a blob of image type. Preferably html that was saved as an image
@Daddyjs
@Daddyjs 2 года назад
Is there a way to update the data and always have it saved to the same link for like sharing this link with other third party calendars so you don’t have to always put in a new link
@SpinSpire
@SpinSpire Год назад
Very good question. Unfortunately, that is not possible, at least not the client-side. This would have to be implemented on the server.
@darunit
@darunit 3 года назад
How to download a div as image using javascript
@SpinSpire
@SpinSpire 3 года назад
I'm sorry I don't understand the question. A DIV has no visual representation. So have can one turn it into an IMG? The question doesn't make sense its current form.
@kalyanivenna6399
@kalyanivenna6399 2 месяца назад
This will not work in Mobile app. Please help me with alternative
@ichitti1434
@ichitti1434 3 года назад
Can you please make a video about downloading a pdf file from blob url android webview app
@rosalyna_24
@rosalyna_24 3 года назад
but if i want to download a pdf that i have uploaded and made some changes in it what should i do ??
@SpinSpire
@SpinSpire 3 года назад
This technique is for generating (building) files on the CLIENT-side (ON the user's browser), and making them downloadable. What you're asking for is downloading a file from SERVER-side. That's a completely different problem that this solution has nothing to do with. Solution for that depends on a lot of server-side details, which is out-of-scope of this video. Having said that, there are ways to "upload" local files into the client-side app itself, read them, manipulate them, and make them downloadable -- without ever touching the server. Is that what you want? Again, keep in mind, that in that case the file never be sent to the server. It will stay within the client (user's browser) and be available to JavaScript for manipulation.
@rosalyna_24
@rosalyna_24 3 года назад
@@SpinSpire yeah that's what i want like i have already uploaded the pdf and edited it then i want to download it but didn't knowhow to do that
@ichitti1434
@ichitti1434 2 года назад
Can you create a video on how to download a pdf from blob data URL? Any help would be great!
@aravindkumar4744
@aravindkumar4744 2 года назад
Hi, Did you get the solution for your query ? Am having the same question for one of my project.
@debankanchatterjee1802
@debankanchatterjee1802 Год назад
how to download a blob url video please help me
@starry_code
@starry_code 2 года назад
Can I download in .rtf format as well?
@SpinSpire
@SpinSpire Год назад
Any file format works as long as you can write client-side JS code that can generate that file.
@midsummer8307
@midsummer8307 Год назад
I'm not able to generate pdf it does not open
@subba18
@subba18 2 года назад
This does not work in Chrome Iphone/IPad.
@dotNet6
@dotNet6 3 года назад
Video tag in same method
@rohithpatelpurella2418
@rohithpatelpurella2418 4 года назад
how to download blob links or how to decode it into normal link to use in html
@SpinSpire
@SpinSpire 4 года назад
That is exactly what this video is about. So please watch it.
@skinnybuddha74
@skinnybuddha74 3 года назад
There has to be an easier way to do this without knowing code.
@Virvos-vd8py
@Virvos-vd8py 6 месяцев назад
no es lo que busco, se pasa saltandose un paso, te lo copiaré, e insistiré
@Virvos-vd8py
@Virvos-vd8py 6 месяцев назад
i need to set a localhost without prompt of download and choose where to save in client computer... i need to save that in localhost.server.wam.etc and not loose the fish.
Далее
Deep Dive into Blobs, Files, and ArrayBuffers
17:42
Просмотров 35 тыс.
Blobs and Blob URLs | JavaScript Tutorial
15:32
Просмотров 25 тыс.
INSTANT File Downloads with JavaScript
21:05
Просмотров 160 тыс.
how Google writes gorgeous C++
7:40
Просмотров 839 тыс.
URL to File/Blob in JavaScript
10:14
Просмотров 52 тыс.
David Flanagan: Bytes and blobs
44:58
Просмотров 10 тыс.
JavaScript FileReader
15:08
Просмотров 137 тыс.