-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor createMultipartRequestBody to support custom content types a… #204
Conversation
return nil, "", err | ||
} | ||
if err := writer.Close(); err != nil { | ||
log.Error("Failed to close writer", zap.Error(err)) |
Check warning
Code scanning / Golang security checks by gosec
Errors unhandled. Warning
} | ||
// addFilePart adds a file part to the multipart writer with the provided field name and file path. | ||
func addFilePart(writer *multipart.Writer, fieldName, filePath string, contentTypes map[string]string, headersMap map[string]http.Header, log logger.Logger) error { | ||
file, err := os.Open(filePath) |
Check failure
Code scanning / Golang security checks by gosec
Potential file inclusion via variable Error
return err | ||
} | ||
if _, err := fieldWriter.Write([]byte(val)); err != nil { | ||
log.Error("Failed to write form field", zap.String("key", key), zap.Error(err)) |
Check warning
Code scanning / Golang security checks by gosec
Errors unhandled. Warning
func addFormField(writer *multipart.Writer, key, val string, log logger.Logger) error { | ||
fieldWriter, err := writer.CreatePart(FormDataHeader(key, "text/plain")) | ||
if err != nil { | ||
log.Error("Failed to create form field", zap.String("key", key), zap.Error(err)) |
Check warning
Code scanning / Golang security checks by gosec
Errors unhandled. Warning
|
||
progressLogger := logUploadProgress(fileSize.Size(), log) | ||
if err := chunkFileUpload(file, part, log, progressLogger); err != nil { | ||
log.Error("Failed to copy file content", zap.String("filePath", filePath), zap.Error(err)) |
Check warning
Code scanning / Golang security checks by gosec
Errors unhandled. Warning
return body, writer.FormDataContentType(), nil | ||
fileSize, err := file.Stat() | ||
if err != nil { | ||
log.Error("Failed to get file info", zap.String("filePath", filePath), zap.Error(err)) |
Check warning
Code scanning / Golang security checks by gosec
Errors unhandled. Warning
if err != nil { | ||
log.Error("Failed to close writer", zap.Error(err)) | ||
return nil, "", err | ||
log.Error("Failed to create form file part", zap.String("fieldName", fieldName), zap.Error(err)) |
Check warning
Code scanning / Golang security checks by gosec
Errors unhandled. Warning
func addFilePart(writer *multipart.Writer, fieldName, filePath string, contentTypes map[string]string, headersMap map[string]http.Header, log logger.Logger) error { | ||
file, err := os.Open(filePath) | ||
if err != nil { | ||
log.Error("Failed to open file", zap.String("filePath", filePath), zap.Error(err)) |
Check warning
Code scanning / Golang security checks by gosec
Errors unhandled. Warning
…nd headers
Change
Type of Change
Please DELETE options that are not relevant.
Checklist