Skip to content

Commit

Permalink
Merge pull request #40 from ezekielriva/change_permissions_after_storage
Browse files Browse the repository at this point in the history
Use carrierwave permission config to set the file permissions
  • Loading branch information
luan committed Nov 1, 2017
2 parents b12f030 + 820e1db commit b87309b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/carrierwave/storage/ftp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def store(file)
ftp.mkdir_p(::File.dirname "#{@uploader.ftp_folder}/#{path}")
ftp.chdir(::File.dirname "#{@uploader.ftp_folder}/#{path}")
ftp.put(file.path, filename)
ftp.sendcmd("SITE CHMOD #{@uploader.permissions.to_s(8)} #{@uploader.ftp_folder}/#{path}")
end
end

Expand Down
3 changes: 3 additions & 0 deletions spec/ftp_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class FtpUploader < CarrierWave::Uploader::Base
ftp.should_receive(:mkdir_p).with('~/public_html/uploads')
ftp.should_receive(:chdir).with('~/public_html/uploads')
ftp.should_receive(:put).with(@file.path, 'test.jpg')
ftp.should_receive(:sendcmd).with("SITE CHMOD 644 ~/public_html/uploads/test.jpg")
ftp.should_receive(:quit)
@stored = @storage.store!(@file)
end
Expand All @@ -52,6 +53,7 @@ class FtpUploader < CarrierWave::Uploader::Base
ftp.stub(:mkdir_p)
ftp.stub(:chdir)
ftp.stub(:put)
ftp.stub(:sendcmd)
ftp.stub(:quit)
@stored = @storage.store!(@file)
end
Expand All @@ -75,6 +77,7 @@ class FtpUploader < CarrierWave::Uploader::Base
@ftp.stub(:mkdir_p)
@ftp.stub(:chdir)
@ftp.stub(:put)
@ftp.stub(:sendcmd)
@ftp.stub(:quit)
@stored = @storage.store!(@file)
end
Expand Down

0 comments on commit b87309b

Please sign in to comment.