Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我需要解码 base64 压缩的 pdf 文件并将解码的数据写入 tempfile 。并且需要将其保存在本地文件 system.in rails 上。
decoded_data=Base64.decode64(encoded_data) file_name = "test.zip" temp_file = Tempfile.new("filename-#{Time.now}") File.open(temp_file, 'wb') {|f| f.write(decoded_data)} send_file temp_file.path, :type => 'application/zip', :filename => file_name