Skip to content

Commit

Permalink
Fix url request type
Browse files Browse the repository at this point in the history
  • Loading branch information
vegarsti committed Feb 12, 2022
1 parent abe40f6 commit 01ab4c1
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion cmd/lambda/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,13 +265,16 @@ func getFile(decodedBodyBytes []byte, contentTypeHeader string) (*extract.File,
if err != nil {
return nil, fmt.Errorf("failed to read response from url fetch: %w", err)
}
if len(bs) == 0 {
return nil, fmt.Errorf("empty response from url")
}
if strings.Contains(u, ".pdf") {
return extract.NewPDF(bs), nil
}
if strings.Contains(u, ".jpg") || strings.Contains(u, ".jpeg") {
return extract.NewJPG(bs), nil
}
return &extract.File{Bytes: bs, ContentType: extract.PNG}, nil
return extract.NewPNG(bs), nil
}
if mediaType == "image/png" {
return extract.NewPNG(decodedBodyBytes), nil
Expand Down

0 comments on commit 01ab4c1

Please sign in to comment.