Skip to content

v2.2.0: Limit upload sizes with maxFileSize

Compare
Choose a tag to compare
@mmcc mmcc released this 02 Dec 05:48
· 110 commits to master since this release
908c9e3

A common ask we've gotten is "how do I limit the upload size?" Well...the better pedantic answer is you should make sure to limit your uploads on the server, but it's only nice to also do so in the client. You don't want someone to spend all that time successfully uploading a huge file that breaks the rules.

Changelog

maxFileSize option

@pchang211 added a new option, maxFileSize, which allows you to specify (in kilobytes) the max file size to allow someone to initialize an upload with. If the file ends up being too large, the UpChunk instance will throw an error.

const upload = UpChunk.createUpload({
  endpoint: "https://example.com/upload/server/address,
  file: picker.files[0],
  maxFileSize: 20480, // Max file size of 20mb
});