luan / carrierwave-ftp

Allows file upload using FTP for CarrierWave uploaders.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

sftp_folder doesn't work with absolute path

jschroeder9000 opened this issue · comments

I ran into an issue with specifying an absolute path to config.sftp_folder. The root of the issue is that the monkey-patched Net::SFTP::Session#mdir_p! can never have a leading '/' in its current implementation. So if I specify

config.sftp_folder = '/foo/bar'

then mkdir_p! creates directories relative to the entry point of the sftp session (the home directory of the sftp user) creating '/home/sftp_user/foo/bar' instead of '/foo/bar'. Then the call to sftp.upload! in the store function correctly uses the absolute path, but the necessary directories weren't created correctly so the upload fails.

I will submit a pull request with a proposed solution shortly.