lib/carrierwave/storage/ftp.rb in carrierwave-ftp-0.2.0 vs lib/carrierwave/storage/ftp.rb in carrierwave-ftp-0.2.1

- old
+ new

@@ -51,30 +51,36 @@ def exists? size ? true : false end def read - http_get_body(url) + file.body end + def content_type + @content_type || file.content_type + end + + def content_type=(new_content_type) + @content_type = new_content_type + end + def delete connection do |ftp| ftp.chdir(::File.dirname "#{@uploader.ftp_folder}/#{path}") ftp.delete(filename) end end private - def http_get_body(url) + def file require 'net/http' url = URI.parse(url) req = Net::HTTP::Get.new(url.path) - res = Net::HTTP.start(url.host, url.port) do |http| + Net::HTTP.start(url.host, url.port) do |http| http.request(req) end - - res.body end def connection ftp = ExFTP.open(@uploader.ftp_host, @uploader.ftp_user, @uploader.ftp_passwd, @uploader.ftp_port) ftp.passive = @uploader.ftp_passive