Add change summaries, inline diff hunks and screenshots to reviews
This commit is contained in:
@@ -10,20 +10,11 @@ import (
|
||||
"g.fc.run/misc/byre/internal/store"
|
||||
)
|
||||
|
||||
const maxBlobBytes = 5 << 20
|
||||
|
||||
var imageTypes = map[string]bool{
|
||||
"image/png": true,
|
||||
"image/jpeg": true,
|
||||
"image/gif": true,
|
||||
"image/webp": true,
|
||||
}
|
||||
|
||||
func (s *Server) UploadBlob(w http.ResponseWriter, r *http.Request) {
|
||||
data, err := io.ReadAll(http.MaxBytesReader(w, r.Body, maxBlobBytes))
|
||||
data, err := io.ReadAll(http.MaxBytesReader(w, r.Body, store.MaxBlobBytes))
|
||||
maxErr := &http.MaxBytesError{}
|
||||
if errors.As(err, &maxErr) {
|
||||
writeError(w, http.StatusRequestEntityTooLarge, fmt.Errorf("images are limited to %d MiB", maxBlobBytes>>20))
|
||||
writeError(w, http.StatusRequestEntityTooLarge, fmt.Errorf("images are limited to %d MiB", store.MaxBlobBytes>>20))
|
||||
return
|
||||
}
|
||||
if err != nil {
|
||||
@@ -32,7 +23,7 @@ func (s *Server) UploadBlob(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
contentType := http.DetectContentType(data)
|
||||
if !imageTypes[contentType] {
|
||||
if !store.ImageTypes[contentType] {
|
||||
writeError(w, http.StatusBadRequest, fmt.Errorf("unsupported image type %s; use PNG, JPEG, GIF or WebP", contentType))
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user