Add content type assertion fallback for JSON file imports
This commit is contained in:
@@ -84,7 +84,7 @@ func (svc *importSession) Create(ctx context.Context, f io.ReadSeeker, name, con
|
||||
}
|
||||
|
||||
f.Seek(0, 0)
|
||||
if jd.CanDecodeFile(f) {
|
||||
if jd.CanDecodeFile(f) || jd.CanDecodeMime(contentType) {
|
||||
f.Seek(0, 0)
|
||||
return jd.Decode(ctx, f, do)
|
||||
}
|
||||
|
||||
@@ -48,6 +48,10 @@ func (d *decoder) CanDecodeFile(f io.Reader) bool {
|
||||
return d.CanDecodeExt(ext)
|
||||
}
|
||||
|
||||
func (d *decoder) CanDecodeMime(m string) bool {
|
||||
return m == "application/json" || m == "application/jsonlines"
|
||||
}
|
||||
|
||||
func (d *decoder) CanDecodeExt(ext string) bool {
|
||||
pt := strings.Split(ext, ".")
|
||||
ext = strings.TrimSpace(pt[len(pt)-1])
|
||||
|
||||
Reference in New Issue
Block a user