cavaliergopher / grab

A download manager package for Go
BSD 3-Clause "New" or "Revised" License
1.39k stars 150 forks source link

Get files as []byte, instead of saving to disk #60

Closed rogierlommers closed 5 years ago

rogierlommers commented 5 years ago

Did you ever consider GET'ting files to []bytes, instead of writing to disk?

cavaliercoder commented 5 years ago

This hasn't come up as a needed feature. You can already transfer files to []byte using the standard library. This package is more useful for writing to disk - resolving a file name, managing the file handle, resuming, etc.

Do you have a specific use case I could consider?

rogierlommers commented 5 years ago

Yeah, I now indeed use the std lib for downloading into a []byte. So no real need. But sometimes it could be useful to have the option in your grab package as well, if you don't want to develop the request + performRequest yourself.

Kind of laziness I think :).

cavaliercoder commented 5 years ago

Haha sounds fair. I'll keep this in mind and leave open for now, thanks!

cavaliercoder commented 5 years ago

You may now store downloads in memory by setting Request.NoStore. Access the raw bytes with Response.Open or Response.Bytes. Feedback welcome 🍻

rogierlommers commented 5 years ago

Thanks!

rogierlommers commented 5 years ago

Hey, it's working fine. One thing though: can you make a release out of it? "dep" ensuring your package now uses tag 2.0, which doesn't contain the new features.