Skip to content

Commit

Permalink
Ensure split chunks are written as binary to avoid errors such as Enc…
Browse files Browse the repository at this point in the history
…oding::UndefinedConversionError: "\x89" from ASCII-8BIT to UTF-8
  • Loading branch information
pgib authored and sferik committed Nov 28, 2023
1 parent 9e7c7f1 commit c6e257f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/x/media_uploader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def split(file_path, chunk_size)
File.open(file_path, "rb") do |f|
while (chunk = f.read(chunk_size))
file_paths << "#{Dir.mktmpdir}/x#{format("%03d", file_number += 1)}".tap do |path|
File.write(path, chunk)
File.binwrite(path, chunk)
end
end
end
Expand Down

0 comments on commit c6e257f

Please sign in to comment.