Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Make SFTP upload file as tempfile #244

Open
casaper opened this issue Dec 1, 2020 · 1 comment
Open

Fix: Make SFTP upload file as tempfile #244

casaper opened this issue Dec 1, 2020 · 1 comment

Comments

@casaper
Copy link
Collaborator

casaper commented Dec 1, 2020

File.write(File.join('tmp', filename), content)

It is not suggested to save such a file like that. This should be done with Ruby std-lib Tempfile.

The way this is implemented now is not advised as is, neither security nor stability wise.

But the good news is, that this is very easy to implement.

@casaper
Copy link
Collaborator Author

casaper commented Dec 1, 2020

require 'tempfile'
tempfile = Tempfile.new(filename)
tempfile.write(rendered_xlsx)
Net::SFTP.start(ENV['SFTP_HOST'], ENV['SFTP_USER'], password: ENV['SFTP_PASS']) do |sftp|
  sftp.upload!(tempfile.path, filename)
end
tempfile.unlink

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant