Add option to limit maximum length of the upload

When the length of the stream is unknown, it might be useful to limit the maximum upload size. If the max size is reached, abort the upload.