I suppose it could be a reader, but I can't think of a way to be smart
about reading the data (i.e reading a specific part without reading
the rest of the parts). If the reader would be an interface to a byte
array, than why not just provide the byte array?
If there's a hard-coded limit to file size, the server could just
throw a 413 error if people try uploading a massive file. It could be
small by default (like 50 MB).
- Mike
On May 2, 6:10 pm, Andrew Gerrand <
a...@golang.org> wrote:
> On 1 May 2010 05:56, Michael Hoisie <
hoi...@gmail.com> wrote:
>
>
>
>
>
> > A while back I implemented this feature in my web framework, and I'd
> > like to add it to the http package. The implementation in web.go has
> > been tested with all browsers for the past couple months, and it works
> > well. Adding it to http will also let me delete some code from
> > web.go :)
>
> > Here's the way I did it (you can also see the code at
> >
http://github.com/hoisie/web.go/blob/master/request.go)
>
> > 1) create a new type filedata:
>
> > type filedata struct {
> > Filename string
> > Data []byte
> > }
>
> > 2) Add a field 'Files' to request, which has type []filedata. This is
> > initially empty, but when request.ParseForm is called and the request
> > containsmultipart/form-data, it gets filled in.
>
> > 3) The files are read into memory all at once.
>
> I understand the implementation reasons for this, but is there a
> better way? How is themultipartdata encoded in an HTTP request? It