rest apis in golang accepting a file upload and another API to stream the file content
1,857 views
Skip to first unread message
suman....@gmail.com
unread,
Nov 26, 2015, 9:15:16 PM11/26/15
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Sign in to report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to golang-nuts
Is there any example of uploading a file to Rest API (POST) implemented using Gorilla library in Go? This API should be accessible via curl, chrome Rest client or any other http rest clients. Examples I googled show uploading from a web page Form.
Giulio Iotti
unread,
Nov 27, 2015, 10:48:36 AM11/27/15
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Sign in to report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to golang-nuts, suman....@gmail.com
On Friday, November 27, 2015 at 4:15:16 AM UTC+2, suman....@gmail.com wrote:
Is there any example of uploading a file to Rest API (POST) implemented using Gorilla library in Go? This API should be accessible via curl, chrome Rest client or any other http rest clients. Examples I googled show uploading from a web page Form.
You don't really need Gorilla to do this, unless you have complicated routes (URL paths for actions); in that case use Gorilla mux.
For uploading a file, there are plenty of examples, for example this[1].
To "stream" a file, just open it and use the resulting Reader in io.Copy() on the http.ResponseWriter: io.Copy(respWriter, fileReader).
You do not have permission to delete messages in this group
Copy link
Report message
Sign in to report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to golang-nuts
On Sat, Nov 28, 2015 at 02:38:22PM -0800, suman....@gmail.com wrote:
> Thanks for the response. But io,Copy is failing while dealing with large
> files (570MB).
You do not have permission to delete messages in this group
Copy link
Report message
Sign in to report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to golang-nuts, suman....@gmail.com
My bad. It works perfect with io,Copy. Thanks.
On Thursday, November 26, 2015 at 8:15:16 PM UTC-6, suman....@gmail.com wrote:
rugwir...@gmail.com
unread,
Apr 19, 2018, 12:06:21 PM4/19/18
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Sign in to report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to golang-nuts
Actually I have almost the same scenario: I am trying to upload large files as a stream. Do you think the io.Copy() method would work for me? If not what do you recommend.