Documentation
¶
Overview ¶
Package uploadhandler implements a simple handler for HTTP file uploads.
Copyright © 2019 M.Watermann, 10247 Berlin, Germany
All rights reserved
EMail : <support@mwat.de>
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
You should have received a copy of the GNU General Public License along with this program. If not, see the [GNU General Public License](http://www.gnu.org/licenses/gpl.html) for details.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Wrap ¶
func Wrap(aHandler http.Handler, aDestDir, aFieldName, anUpURL, aNextURL string, aMaxSize int64, aPager errorhandler.TErrorPager) http.Handler
Wrap returns a handler function that includes error page handling, wrapping the given `aHandler` and calling it internally.
`aHandler` the previous handler responding to the HTTP request.
`aDestDir` is the directory to place the uploaded files.
`aFieldName` the name/ID of the form/input holding the uploaded file.
`anUpURL` the URL uploads are POSTed to.
`aNextURL` the URL to redirect the user after a asuccessful upload.
`aMaxSize` the max. accepted size of uploaded files.
`aPager` optional provider of error message pages (or `nil` if not needed).
Types ¶
type TUploadHandler ¶
type TUploadHandler struct {
// contains filtered or unexported fields
}
TUploadHandler embeds a `TErrorPager` which provides error page handling.
func NewHandler ¶
func NewHandler(aDestDir, aFieldName, anUpURL, aNextURL string, aMaxSize int64, aPager errorhandler.TErrorPager) *TUploadHandler
NewHandler returns a new `tUploadHandler` instance.
`aDestDir` is the directory to place the uploaded files.
`aFieldName` the name/ID of the form/input holding the uploaded file.
`anUpURL` the URL uploads are POSTed to.
`aNextURL` the URL to redirect the user after a asuccessful upload.
`aMaxSize` the max. accepted size of uploaded files.
`aPager` optional provider of error message pages (or `nil` if not needed).
func (TUploadHandler) ServeHTTP ¶
func (uh TUploadHandler) ServeHTTP(aWriter http.ResponseWriter, aRequest *http.Request) (string, int)
ServeHTTP handles the incoming file upload.
`aWriter` writes the response to the remote user.
`aRequest` is the incoming upload request.