mirror of
https://github.com/docusealco/docuseal
synced 2026-11-16 08:12:32 -05:00
zip size limit
This commit is contained in:
1 parent
e5b9ee9502
commit
cd5cb9c082
1 file changed
+6
-4
@@ -100,13 +100,15 @@ module Templates
|
|||||||
Zip::File.open(file.tempfile).each do |entry|
|
Zip::File.open(file.tempfile).each do |entry|
|
||||||
next if entry.directory?
|
next if entry.directory?
|
||||||
|
|
||||||
total_size += entry.size
|
tempfile = Tempfile.new(entry.name)
|
||||||
|
tempfile.binmode
|
||||||
|
|
||||||
|
total_size += entry.get_input_stream do |in_stream|
|
||||||
|
IO.copy_stream(in_stream, tempfile, MAX_ZIP_SIZE - total_size + 1)
|
||||||
|
end
|
||||||
|
|
||||||
raise InvalidFileType, 'zip_too_large' if total_size > MAX_ZIP_SIZE
|
raise InvalidFileType, 'zip_too_large' if total_size > MAX_ZIP_SIZE
|
||||||
|
|
||||||
tempfile = Tempfile.new(entry.name)
|
|
||||||
tempfile.binmode
|
|
||||||
entry.get_input_stream { |in_stream| IO.copy_stream(in_stream, tempfile) }
|
|
||||||
tempfile.rewind
|
tempfile.rewind
|
||||||
|
|
||||||
type = Marcel::MimeType.for(tempfile, name: entry.name)
|
type = Marcel::MimeType.for(tempfile, name: entry.name)
|
||||||
|
|||||||
Reference in new issue
Block a user