Skip to content

Commit

Permalink
Merge pull request #224 from deploymenttheory/dev-multipartfix
Browse files Browse the repository at this point in the history
Refactor chunk size for file upload in multipart request to 10MB per …
  • Loading branch information
ShocOne authored Jun 6, 2024
2 parents 5bf47a5 + c720348 commit 976aea3
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions httpclient/multipartrequest.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func (c *Client) DoMultiPartRequest(method, endpoint string, files map[string][]
return nil, err
}

log.Debug("Executing multipart request", zap.String("method", method), zap.String("endpoint", endpoint))
log.Info("Executing multipart request", zap.String("method", method), zap.String("endpoint", endpoint))

// body, contentType, err := createMultipartRequestBody(files, formDataFields, fileContentTypes, formDataPartHeaders, log)
// if err != nil {
Expand Down Expand Up @@ -339,7 +339,7 @@ func setFormDataPartHeader(fieldname, filename, contentType string, customHeader
// - error: An error object indicating failure during the file upload. This could be due to issues such as file reading errors
// or writer errors.
func chunkFileUpload(file *os.File, writer io.Writer, log logger.Logger, updateProgress func(int64)) error {
const chunkSize = 5124 * 1024 // 5124 KB in bytes (5 MB)
const chunkSize = 10240 * 1024 // 5124 KB in bytes (5 MB)
buffer := make([]byte, chunkSize)
totalWritten := int64(0)
chunkWritten := int64(0)
Expand Down Expand Up @@ -404,8 +404,8 @@ func logUploadProgress(fileSize int64, log logger.Logger) func(int64) {

if percentage >= lastLoggedPercentage+logInterval {
log.Info("Upload progress",
zap.Int64("uploaded_bytes", uploaded),
zap.Int64("total_bytes", fileSize),
zap.Int64("uploaded_kbs", uploaded/1024),
zap.Int64("total_filesize_in_kb", fileSize/1024),
zap.String("percentage", fmt.Sprintf("%d%%", percentage)))
lastLoggedPercentage = percentage
}
Expand Down

0 comments on commit 976aea3

Please sign in to comment.