I’m trying to create PDFs that can be stored on an external server.
I do this:
File.new("temp.pdf", "w").close
File.open("temp.pdf", "wb") do |f|
f.write(bytes)
end
File.open("temp.pdf", "r") do |f|
# upload `f` to server
end
File.delete("temp.pdf")
then upload them to the server.
On my local machine this works fine, but, I recently tried running on another machine, and I got a permissions error in the log.
Is there a way to:
- Write bytes to a file.
- Never touch the hard disk.
Why don’t you just upload the bytes to the server?
You may have to go a little lower-level than normal, but check for instance the
UploadIOclass of themultipart-postgem.