mirror of
https://github.com/Forceu/Gokapi.git
synced 2026-01-05 08:19:49 -06:00
Fixed Gokapi not parsing parameters when uploading through API #31
This commit is contained in:
2
go.mod
2
go.mod
@@ -1,6 +1,6 @@
|
||||
module Gokapi
|
||||
|
||||
go 1.16
|
||||
go 1.17
|
||||
|
||||
require (
|
||||
github.com/aws/aws-sdk-go v1.38.36
|
||||
|
||||
@@ -80,7 +80,6 @@ func TestProcess(t *testing.T) {
|
||||
test.ResponseBodyContains(t, w, "Invalid request")
|
||||
}
|
||||
|
||||
|
||||
func TestAuthDisabledLogin(t *testing.T) {
|
||||
w, r := getRecorder("GET", "/api/auth/friendlyname", nil, nil, nil)
|
||||
Process(w, r, maxMemory)
|
||||
@@ -163,6 +162,9 @@ func TestUpload(t *testing.T) {
|
||||
part, err := writer.CreateFormFile("file", filepath.Base(file.Name()))
|
||||
test.IsNil(t, err)
|
||||
io.Copy(part, file)
|
||||
writer.WriteField("allowedDownloads", "200")
|
||||
writer.WriteField("expiryDays", "10")
|
||||
writer.WriteField("password", "12345")
|
||||
writer.Close()
|
||||
w, r := getRecorder("POST", "/api/files/add", nil, []test.Header{{
|
||||
Name: "apikey",
|
||||
@@ -178,6 +180,8 @@ func TestUpload(t *testing.T) {
|
||||
test.IsNil(t, err)
|
||||
test.IsEqualString(t, result.Result, "OK")
|
||||
test.IsEqualString(t, result.FileInfo.Size, "3 B")
|
||||
test.IsEqualInt(t, result.FileInfo.DownloadsRemaining, 200)
|
||||
test.IsNotEqualString(t, result.FileInfo.PasswordHash, "")
|
||||
test.IsEqualString(t, result.Url, "http://127.0.0.1:53843/d?id=")
|
||||
w, r = getRecorder("POST", "/api/files/add", nil, []test.Header{{
|
||||
Name: "apikey",
|
||||
|
||||
@@ -21,7 +21,7 @@ func Process(w http.ResponseWriter, r *http.Request, isWeb bool, maxMemory int)
|
||||
if isWeb {
|
||||
config = parseConfig(r.Form, true)
|
||||
} else {
|
||||
config = parseConfig(r.Header, false)
|
||||
config = parseConfig(r.Form, false)
|
||||
}
|
||||
file, header, err := r.FormFile("file")
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user