mirror of
https://github.com/kataras/iris.git
synced 2026-01-10 13:35:59 +00:00
Update the _examples/http_request/upload-file to fill the gap, relative discussion: https://github.com/kataras/iris/issues/979
Former-commit-id: a113e8815a6a2821a80ac424f52302528a6e71b5
This commit is contained in:
@@ -432,6 +432,10 @@ type Context interface {
|
||||
// which may, setted before with the 'ContentType'.
|
||||
GetContentType() string
|
||||
|
||||
// GetContentLength returns the request's header value of "Content-Length".
|
||||
// Returns 0 if header was unable to be found or its value was not a valid number.
|
||||
GetContentLength() int64
|
||||
|
||||
// StatusCode sets the status code header to the response.
|
||||
// Look .GetStatusCode too.
|
||||
StatusCode(statusCode int)
|
||||
@@ -1597,6 +1601,16 @@ func (ctx *context) GetContentType() string {
|
||||
return ctx.writer.Header().Get(ContentTypeHeaderKey)
|
||||
}
|
||||
|
||||
// GetContentLength returns the request's header value of "Content-Length".
|
||||
// Returns 0 if header was unable to be found or its value was not a valid number.
|
||||
func (ctx *context) GetContentLength() int64 {
|
||||
if v := ctx.GetHeader(ContentLengthHeaderKey); v != "" {
|
||||
n, _ := strconv.ParseInt(v, 10, 64)
|
||||
return n
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
// StatusCode sets the status code header to the response.
|
||||
// Look .GetStatusCode & .FireStatusCode too.
|
||||
//
|
||||
@@ -1966,7 +1980,10 @@ func (ctx *context) FormFile(key string) (multipart.File, *multipart.FileHeader,
|
||||
// here but do it in order to apply the post limit,
|
||||
// the internal request.FormFile will not do it if that's filled
|
||||
// and it's not a stream body.
|
||||
ctx.request.ParseMultipartForm(ctx.Application().ConfigurationReadOnly().GetPostMaxMemory())
|
||||
if err := ctx.request.ParseMultipartForm(ctx.Application().ConfigurationReadOnly().GetPostMaxMemory()); err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
return ctx.request.FormFile(key)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user