3 ms·
I am currently searching for an example / skeleton in Go where I can upload a file via the browser to the server (drag and drop added bonus). Any examples?
by jhoechtl 10y ago
I am currently searching for an example / skeleton in Go where I can upload a file via the browser to the server (drag and drop added bonus). Any examples?
- merlish 10y agoI actually wrote an extremely shonky/basic file upload thing and contributed it to the weird 'illacceptanything' repository, while that was a thing, about a year and a half ago. Maybe you'll find it helpful, maybe not. Ignore the bindata.go stuff and look at main.go (inc. file accepting) & the file upload control (w/Bootstrap fileinput.min.js) & the braindead simple HTML templating stuff. https://github.com/leafi/illacceptanything/commit/1b78922f891e455d56df9632740e3f9a62ee6009 https://github.com/leafi/illacceptanything/commit/1b78922f89...
- lesiki 10y agoI don't know much about Go so can't speak to the server-side handling of file uploads. The drag/drop side of things is server agnostic - I strongly recommend http://www.dropzonejs.com http://www.dropzonejs.com
- lentil 10y agoThis might be more of a complete app than you need, but https://transfer.sh https://transfer.sh is open source and it looks fairly compact. Could be some interesting examples in there?
- Spiritus 10y agoSomething like this will hopefully get the point across on how to handle "multipart/form-data" forms. It will print the content of the upload to the server's stdout. https://play.golang.org/p/DiNGdl27kE https://play.golang.org/p/DiNGdl27kE You can use curl to test it out (it assumes a file called "foobar.txt" is available): curl -v -F upload=@foobar.txt localhost:8080/upload
- bitexploder 10y agoI really like the gophish app for easy to understand common patterns in web apps.