Skip to content

Commit

Permalink
Minor fix
Browse files Browse the repository at this point in the history
  • Loading branch information
royroyee committed Aug 22, 2024
1 parent fa03206 commit 8dcc201
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion api/ftp/ftp.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ func UploadFile(ac *client.AlpaconClient, src []string, dest, username, groupnam
if err != nil {
return nil, err
}
defer func() { _ = writer.Close() }()
_ = writer.Close()

respBody, err := ac.SendMultipartRequest(uploadAPIURL, writer, requestBody)
if err != nil {
return nil, err
Expand Down
8 changes: 4 additions & 4 deletions api/packages/packages.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,17 +144,17 @@ func UploadPackage(ac *client.AlpaconClient, file string, packageType string) er
}

var requestBody bytes.Buffer
multiPartWriter := multipart.NewWriter(&requestBody)
writer := multipart.NewWriter(&requestBody)

fileWriter, err := multiPartWriter.CreateFormFile("content", file)
fileWriter, err := writer.CreateFormFile("content", file)
if err != nil {
return err
}
_, err = fileWriter.Write(content)
if err != nil {
return err
}
multiPartWriter.Close()
_ = writer.Close()

var requestURL string
if packageType == "python" {
Expand All @@ -163,7 +163,7 @@ func UploadPackage(ac *client.AlpaconClient, file string, packageType string) er
requestURL = systemPackageEntryURL
}

_, err = ac.SendMultipartRequest(requestURL, multiPartWriter, requestBody)
_, err = ac.SendMultipartRequest(requestURL, writer, requestBody)
if err != nil {
return err
}
Expand Down

0 comments on commit 8dcc201

Please sign in to comment.