1
0
mirror of https://github.com/drakkan/sftpgo.git synced 2025-12-05 22:17:20 +02:00

REST API: add an option to create missing dirs

This commit is contained in:
Nicola Murino
2021-12-19 12:14:53 +01:00
parent cc73bb811b
commit ced73ed04e
13 changed files with 290 additions and 24 deletions

View File

@@ -91,14 +91,15 @@ func getRespStatus(err error) int {
return http.StatusInternalServerError
}
// mappig between fs errors for HTTP protocol and HTTP response status codes
func getMappedStatusCode(err error) int {
var statusCode int
switch err {
case os.ErrPermission:
switch {
case errors.Is(err, os.ErrPermission):
statusCode = http.StatusForbidden
case os.ErrNotExist:
case errors.Is(err, os.ErrNotExist):
statusCode = http.StatusNotFound
case common.ErrQuotaExceeded:
case errors.Is(err, common.ErrQuotaExceeded):
statusCode = http.StatusRequestEntityTooLarge
default:
statusCode = http.StatusInternalServerError
@@ -128,6 +129,10 @@ func getCommaSeparatedQueryParam(r *http.Request, key string) []string {
return util.RemoveDuplicates(result)
}
func getBoolQueryParam(r *http.Request, param string) bool {
return r.URL.Query().Get(param) == "true"
}
func handleCloseConnection(w http.ResponseWriter, r *http.Request) {
r.Body = http.MaxBytesReader(w, r.Body, maxRequestSize)
connectionID := getURLParam(r, "connectionID")