mirror of
https://github.com/rclone/rclone.git
synced 2025-12-16 00:04:40 +00:00
rc: Add operations/uploadfile to upload a file through rc using encoding multipart/form-data
This commit is contained in:
committed by
Nick Craig-Wood
parent
d0de39ebcd
commit
fa43d02874
@@ -6,6 +6,7 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"math"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
@@ -90,6 +91,23 @@ func (p Params) Get(key string) (interface{}, error) {
|
||||
return value, nil
|
||||
}
|
||||
|
||||
// GetHTTPRequest gets a http.Request parameter associated with the request with the key "HttpRequest"
|
||||
//
|
||||
// If the parameter isn't found then error will be of type
|
||||
// ErrParamNotFound and the returned value will be nil.
|
||||
func (p Params) GetHTTPRequest() (*http.Request, error) {
|
||||
key := "_request"
|
||||
value, err := p.Get(key)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
request, ok := value.(*http.Request)
|
||||
if !ok {
|
||||
return nil, ErrParamInvalid{errors.Errorf("expecting http.request value for key %q (was %T)", key, value)}
|
||||
}
|
||||
return request, nil
|
||||
}
|
||||
|
||||
// GetString gets a string parameter from the input
|
||||
//
|
||||
// If the parameter isn't found then error will be of type
|
||||
|
||||
Reference in New Issue
Block a user