How To Stream Large Files Over TCP In Golang

  Рет қаралды 33,601

Anthony GG

Anthony GG

Күн бұрын

Пікірлер: 56
@anthonygg_
@anthonygg_ Жыл бұрын
► Join my Discord community for free education 👉 discord.com/invite/bDy8t4b3Rz ► Become a Patreon for exclusive tutorials👉 www.patreon.com/anthonygg_ ► Buy me a coffee 👉 donate.stripe.com/aEU2a6ayH2uCa3u4gg Thanks for watching
@joaomendoncayt
@joaomendoncayt 6 ай бұрын
"just use little-endian and drink margaritas at the beach" "not too big because my pc is pepega" these videos are just perfect, perfect pace, perfect content, perfect tone, perfect accent
@ArtemTimofeev-iw5cl
@ArtemTimofeev-iw5cl Жыл бұрын
man... i cant express how much this will do for my cdn in golang... Dear Anthony, bless you😃
@anthonygg_
@anthonygg_ Жыл бұрын
Your welcome my man!
@bashscript2805
@bashscript2805 Жыл бұрын
скинь ссылочку на cdn
@user-fr6gw8xr4b
@user-fr6gw8xr4b 3 ай бұрын
Great video. I saw a few problems with the final solution. In the sendFile you append the size of file to the conn. In readLoop you read that size in the loop which is problem. And even if the size is in out of the loop, this will try to copy the entire byte data from the conn into buf in one go.
@fredericcordier1519
@fredericcordier1519 Жыл бұрын
this video is really great and very educational with the different steps/tests. Thanks for your work, the days are too short to watch all your videos :)
@anthonygg_
@anthonygg_ Жыл бұрын
Thank you!
@jatindersinghaujla
@jatindersinghaujla Жыл бұрын
Before watching this video I just listen what streaming is but today I have seen how actually it works. This streaming concept clear but buffer is and how stream it. Great we are expecting more exciting and interesting videos.
@otaxhu
@otaxhu 9 ай бұрын
Your videos are very helpful, no doubt this is the best golang content creator
@hebozhe
@hebozhe 3 ай бұрын
Go beast! I needed this locally for a 20GB corpus, so thanks for the tips.
@Nexjsdeveloper
@Nexjsdeveloper Жыл бұрын
i need to see ur video over and over! Perfectly fine.
@shoebilyas9664
@shoebilyas9664 3 ай бұрын
your channel is a rare gem
@anthonygg_
@anthonygg_ 3 ай бұрын
Ty
@Alibek11221
@Alibek11221 11 ай бұрын
Like your work! Thank you! Learned a lot through your videos
@deNudge
@deNudge Жыл бұрын
Why are you reading the file size within the for loop?
@L0wPressure
@L0wPressure Жыл бұрын
Yes, it leads to neverending stream of random bytes. Get it above the for loop and it will do what's intended.
@Andika-hk6rd
@Andika-hk6rd 6 ай бұрын
I'm new to programming and I think this is cool, gonna save the video, I think it's useful :)
@bjugdbjk
@bjugdbjk Жыл бұрын
Awesome , Thnx for the amazing Go content.
@Chxrli3
@Chxrli3 2 ай бұрын
Thank you so much for this video :) its really helpful. Do you have any links or videos about parsing from the loop?
@user-hn9xf3oj9h
@user-hn9xf3oj9h 2 ай бұрын
thank you for uploading great video!
@vaibhavmewada4508
@vaibhavmewada4508 4 ай бұрын
nice video anthony
@ollegio
@ollegio 4 ай бұрын
But your first implementation is also a streaming one: you are not reading whole file into memory, you have a fixed buffer which is updated on each Read. I think io.Copy just does the same thing
@anthonygg_
@anthonygg_ 4 ай бұрын
I think io copy is bit more effiecient under the hood.
@lowe7372
@lowe7372 Жыл бұрын
You are the best!
@tonycheng1614
@tonycheng1614 Жыл бұрын
I am very new in go. Can you specify the advantages of streaming file data comparing non-streaming file data in transfer? Thank you sir.
@anthonygg_
@anthonygg_ Жыл бұрын
Non streaming is saving the complete file in memory. Hence 30 gb files will not work on a simple server
@MarinescuEdward
@MarinescuEdward 5 ай бұрын
@@anthonygg_ even with the second appraoch if you send 30 gb file it will still allocate 30 gb of memory `binary.Read(con, binary.LittleEndian, &size)` since size is 30 gb
@9scott291
@9scott291 Жыл бұрын
Thank you for sharing
@jondoe79
@jondoe79 Жыл бұрын
Anthony is a Go Master ultimatum
@anthonygg_
@anthonygg_ Жыл бұрын
The undisputed.
@MaybeAwab
@MaybeAwab Жыл бұрын
the best
@oscarllamas
@oscarllamas Жыл бұрын
Great as always
@ruslangabitov5202
@ruslangabitov5202 6 ай бұрын
Thank you for your video. How will this transmission work if the sender don't know the file size? Is it possible just send the EOF in the end of transmission? Does conn send EOF when the connection closed?
@simo_the_goat
@simo_the_goat 4 ай бұрын
MR Anthony I really appreciate your content. Please I have a small question I want to know why I opened my activity monitor and my RAM is getting too large even though It's streaming
@wMwPlay
@wMwPlay Жыл бұрын
Can I download twitch stream and stream it to youtube upload API directly, using this method?
@anthonygg_
@anthonygg_ Жыл бұрын
That will involve some more work my man
@sovrinfo
@sovrinfo Жыл бұрын
Awesome video. Big thanks. I have a question, if I set size: 400000 program exit with code 1. Error message: recieves 400000 bytes over the network 2022/12/16 20:50:03 EOF Process finished with the exit code 1
@anthonygg_
@anthonygg_ Жыл бұрын
Could be a read or write timeout. You can configure that
@sovrinfo
@sovrinfo Жыл бұрын
@@anthonygg_ Thanks
@oleks19999
@oleks19999 5 ай бұрын
I just don't get one thing, what condition will stop the for loop ? Cause we want to stop it at some point right ?
@fullstack_journey
@fullstack_journey Жыл бұрын
Time to build my own OTT platform startup
@madhudson1
@madhudson1 4 ай бұрын
the for loop on the read with the end solution is a bit redundant i think. Wouldn't this solution just endlessly (for huge files) read into memory anyway? the Buffer will just fill up continuously, instead of allowing you to process x number of bytes?
@anthonygg_
@anthonygg_ 4 ай бұрын
I need to check this, you could be right
@aianshu
@aianshu 4 ай бұрын
Awesome
@tanko.reactions176
@tanko.reactions176 Жыл бұрын
brother, this is the second time i see you sending stuff over the network without taking into account that the operating system can not always send N-bytes just becuase you wish to send N-bytes. it may send N/2.. or much less. if you wish to stream, you have to keep track of a pointer to how much has been send. if N/2 has been send, then you send from N/2 until N.. you can not declare the chunk to be sent, if only a piece of it may be sent. the issue does not occur locally, it occurs when you do this over the net!
@anthonygg_
@anthonygg_ Жыл бұрын
What are you talking about my man. Read net.Conn.
@dazealex
@dazealex 9 ай бұрын
I have no idea what the dude is saying either. RTFM @@tanko.reactions17
@adamsribz
@adamsribz Жыл бұрын
Would be amazing if you could share github snippets with your videos
@anthonygg_
@anthonygg_ Жыл бұрын
Im getting paid way to less for that. This is free content made in my free time. Leeched by many. Returned by a few.
@adamsribz
@adamsribz Жыл бұрын
@@anthonygg_ I feel you! Your hard work shows even in your free stuff.
@ghostbuster5266
@ghostbuster5266 Жыл бұрын
You need read file size before loop 😅
@headlikeahole6548
@headlikeahole6548 7 ай бұрын
How does the method "binary.Read" know where the size data is and where the file data is?
@twitchizle
@twitchizle 6 ай бұрын
Server sends, filesize. Binary reads filesize. Server sends filedata. Binary read file data.
@mjhsaja
@mjhsaja 7 ай бұрын
rand.Reader is missing
How To Refactor A Golang Project By Using Interfaces
18:39
Anthony GG
Рет қаралды 13 М.
How To Use The Context Package In Golang?
17:03
Anthony GG
Рет қаралды 60 М.
Самое неинтересное видео
00:32
Miracle
Рет қаралды 2,3 МЛН
Angry Sigma Dog 🤣🤣 Aayush #momson #memes #funny #comedy
00:16
ASquare Crew
Рет қаралды 49 МЛН
ДОКАЗАЛ ЧТО НЕ КАБЛУК #shorts
00:30
Паша Осадчий
Рет қаралды 1,9 МЛН
Beginners Should Think Differently When Writing Golang
11:35
Anthony GG
Рет қаралды 108 М.
How To Build A Chat And Data Feed With WebSockets In Golang?
20:45
Golang pointers explained, once and for all
13:49
JamieGo
Рет қаралды 7 М.
Five of my favorite project ideas to learn Go.
11:31
Dreams of Code
Рет қаралды 54 М.
Quarkus (Java) vs Fiber (Go): Performance Benchmark in Kubernetes
16:40
Mastering WebSockets With Go - An in-depth tutorial
2:24:34
ProgrammingPercy
Рет қаралды 44 М.
Don't Make this Golang Beginner Mistake!
8:57
Anthony GG
Рет қаралды 23 М.
How I Structure New Projects In Golang
21:32
Anthony GG
Рет қаралды 58 М.
Master Go Programming With These Concurrency Patterns (in 40 minutes)
46:15
Build real-time modern web apps with Go, WebSockets and HTMX
35:11