forge42dev / remix-hook-form

Open source wrapper for react-hook-form aimed at Remix.run
MIT License
330 stars 27 forks source link

Missing Blob type check to file upload V3 #44

Closed Centerworx closed 10 months ago

Centerworx commented 10 months ago

formData can be of type string or blob. The check here only checks for Files so you don't allow for all Blob types. This results in Blobs being validated as objects and going through the Object path, which gets JSON.stringify() and renders them as empty objects on the server.

} else if (value instanceof File) {
      formData.append(key, value);
}

Code Here: https://github.com/Code-Forge-Net/remix-hook-form/pull/41/files#diff-4f4a4192cd629d907783a6baf48c530f39d6a43181dd3515cc46231868e0ed08R155-R156

add these checks to fix: value instanceof Blob || toString.call(value) === "[object Blob]"; instead of value instanceof File the proceeding change will check for Files & Blobs.