(re *core.RequestEvent, collection *core.Collection, prefix string)
| 688 | } |
| 689 | |
| 690 | func extractUploadedFiles(re *core.RequestEvent, collection *core.Collection, prefix string) (map[string][]*filesystem.File, error) { |
| 691 | contentType := re.Request.Header.Get("content-type") |
| 692 | if !strings.HasPrefix(contentType, "multipart/form-data") { |
| 693 | return nil, nil // not multipart/form-data request |
| 694 | } |
| 695 | |
| 696 | result := map[string][]*filesystem.File{} |
| 697 | |
| 698 | for _, field := range collection.Fields { |
| 699 | if field.Type() != core.FieldTypeFile { |
| 700 | continue |
| 701 | } |
| 702 | |
| 703 | baseKey := field.GetName() |
| 704 | |
| 705 | keys := []string{ |
| 706 | baseKey, |
| 707 | // prepend and append modifiers |
| 708 | "+" + baseKey, |
| 709 | baseKey + "+", |
| 710 | } |
| 711 | |
| 712 | for _, k := range keys { |
| 713 | if prefix != "" { |
| 714 | k = prefix + "." + k |
| 715 | } |
| 716 | files, err := re.FindUploadedFiles(k) |
| 717 | if err != nil && !errors.Is(err, http.ErrMissingFile) { |
| 718 | return nil, err |
| 719 | } |
| 720 | if len(files) > 0 { |
| 721 | result[k] = files |
| 722 | } |
| 723 | } |
| 724 | } |
| 725 | |
| 726 | return result, nil |
| 727 | } |
| 728 | |
| 729 | // hasAuthManageAccess checks whether the client is allowed to have |
| 730 | // [forms.RecordUpsert] auth management permissions |
no test coverage detected
searching dependent graphs…