Skip to content

Commit

Permalink
fix(deps): downgrade react-dropzone to fix media uploading on GSIB (#…
Browse files Browse the repository at this point in the history
…1775)

* fix(deps): downgrade react-dropzone to fix media uploading on GSIB

* fix(media): prevent jfif files from being uploaded

* docs(media): add note about restriction of JFIF file format
  • Loading branch information
dcshzj authored Jan 17, 2024
1 parent a9fe95d commit 233044b
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 23 deletions.
49 changes: 38 additions & 11 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
"react-color": "^2.19.3",
"react-diff-viewer": "^3.1.1",
"react-dom": "^18.2.0",
"react-dropzone": "^14.2.3",
"react-dropzone": "^11.7.1",
"react-hook-form": "^7.32.0",
"react-icons": "^4.4.0",
"react-input-mask": "^2.0.4",
Expand Down
10 changes: 10 additions & 0 deletions src/components/Attachment/Attachment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,16 @@ export const Attachment = forwardRef<AttachmentProps, "div">(
message: `File is too big (${getReadableFileSize(file.size)})`,
}
}

// Note: We do not current support this right now on the backend, but
// once we add support for it, we can remove this restriction.
if (file.name.endsWith(".jfif")) {
return {
code: "jfif-file-not-supported",
message:
"The JFIF file format is not supported, please convert to JPEG instead",
}
}
return null
},
[maxSize]
Expand Down
20 changes: 9 additions & 11 deletions src/components/MediaCreationModal/MediaCreationModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,16 @@ import { Dropzone } from "./components/Dropzone"

type MediaSteps = "upload" | "progressing" | "success" | "failed"

const IMAGE_UPLOAD_ACCEPTED_MIME_TYPES = {
"image/jpeg": [".jpg", ".jpeg"],
"image/png": [".png"],
"image/gif": [".gif"],
"image/svg+xml": [".svg"],
"image/tiff": [".tiff", ".tif"],
"image/bmp": [".bmp"],
}
const IMAGE_UPLOAD_ACCEPTED_MIME_TYPES = [
"image/jpeg",
"image/png",
"image/gif",
"image/svg+xml",
"image/tiff",
"image/bmp",
]

const FILE_UPLOAD_ACCEPTED_MIME_TYPES = {
"application/pdf": [".pdf"],
}
const FILE_UPLOAD_ACCEPTED_MIME_TYPES = ["application/pdf"]

interface MediaDropzoneProps {
fileRejections: FileRejection[]
Expand Down

0 comments on commit 233044b

Please sign in to comment.