Skip to content
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

multipart uploads: Hack to support gsutil cp #1182

Merged
merged 2 commits into from
May 27, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion fakestorage/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,18 @@ func getObjectACL(predefinedACL string) []storage.ACLRule {

func (s *Server) multipartUpload(bucketName string, r *http.Request) jsonResponse {
defer r.Body.Close()
_, params, err := mime.ParseMediaType(r.Header.Get(contentTypeHeader))
requestContentType := r.Header.Get(contentTypeHeader)
// gsutil is observed to submit incorrectly-quoted bounary strings
// like: boundary='===============5900997287163282353=='
// See https://github.com/GoogleCloudPlatform/gsutil/issues/1466
// Having an "=" character in the boundary param requires the value be quoted,
// but ' is not a quote char, " is.
// If we see a string like "boundary='=", which is always invalid anyway,
// attempt to rescue the situation by converting all ' to ".
if strings.Contains(requestContentType, "boundary='=") {
requestContentType = strings.ReplaceAll(requestContentType, "'", "\"")
fsouza marked this conversation as resolved.
Show resolved Hide resolved
}
_, params, err := mime.ParseMediaType(requestContentType)
if err != nil {
return jsonResponse{
status: http.StatusBadRequest,
Expand Down