carrierwave-ftp 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/carrierwave/storage/ftp.rb +5 -1
- data/lib/carrierwave/storage/ftp/version.rb +1 -1
- data/lib/carrierwave/storage/sftp.rb +5 -1
- data/spec/ftp_file_spec.rb +37 -0
- data/spec/ftp_spec.rb +1 -2
- data/spec/sftp_file_spec.rb +37 -0
- data/spec/sftp_spec.rb +1 -2
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 551b48c6149faaa78b66b77b7b119c5bd0a42219
|
4
|
+
data.tar.gz: 9e1a295293d824b6fb476280ac7df4d7070abbc7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7740cafb26fd31fb035751504d7b026f4c2af965d4a01e1b8ca9866d4e00acfbf5a49ad838ccc643a744a3ebb68fc2a8edc69cf2d6eee786339464ea2a8031fe
|
7
|
+
data.tar.gz: 24e35b324a658daf03a49e8d57a85d73079fed6c21c3089d8fa4d75be272657df553af1d8a9f05dc39ba9a846700d614df5248d8909eb492870449aa664e0f10
|
@@ -77,7 +77,7 @@ module CarrierWave
|
|
77
77
|
end
|
78
78
|
|
79
79
|
def content_type
|
80
|
-
@content_type ||
|
80
|
+
@content_type || inferred_content_type
|
81
81
|
end
|
82
82
|
|
83
83
|
def content_type=(new_content_type)
|
@@ -94,6 +94,10 @@ module CarrierWave
|
|
94
94
|
|
95
95
|
private
|
96
96
|
|
97
|
+
def inferred_content_type
|
98
|
+
SanitizedFile.new(path).content_type
|
99
|
+
end
|
100
|
+
|
97
101
|
def connection
|
98
102
|
if @uploader.ftp_tls
|
99
103
|
ftp = ExFTPTLS.new
|
@@ -69,7 +69,7 @@ module CarrierWave
|
|
69
69
|
end
|
70
70
|
|
71
71
|
def content_type
|
72
|
-
@content_type ||
|
72
|
+
@content_type || inferred_content_type
|
73
73
|
end
|
74
74
|
|
75
75
|
def content_type=(new_content_type)
|
@@ -85,6 +85,10 @@ module CarrierWave
|
|
85
85
|
|
86
86
|
private
|
87
87
|
|
88
|
+
def inferred_content_type
|
89
|
+
SanitizedFile.new(path).content_type
|
90
|
+
end
|
91
|
+
|
88
92
|
def use_ssl?
|
89
93
|
@uploader.sftp_url.start_with?('https')
|
90
94
|
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'carrierwave/storage/ftp'
|
3
|
+
|
4
|
+
describe CarrierWave::Storage::FTP::File do
|
5
|
+
let(:uploader) do
|
6
|
+
Class.new(CarrierWave::Uploader::Base) do
|
7
|
+
storage :ftp
|
8
|
+
end.tap do |u|
|
9
|
+
allow(u).to receive(:store_path).and_return('uploads/test.jpg')
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
let(:base) { CarrierWave::Storage::FTP.new(uploader) }
|
14
|
+
|
15
|
+
let(:file) do
|
16
|
+
CarrierWave::Storage::FTP::File.new(uploader, base, uploader.store_path)
|
17
|
+
end
|
18
|
+
|
19
|
+
let(:mime_type) { double('mime_type') }
|
20
|
+
|
21
|
+
describe '#content_type' do
|
22
|
+
it 'delegates to base file by default' do
|
23
|
+
sanitized_file = CarrierWave::SanitizedFile.new(file)
|
24
|
+
expect(CarrierWave::SanitizedFile).to receive(:new).with(file.path).
|
25
|
+
and_return(sanitized_file)
|
26
|
+
expect(sanitized_file).to receive(:content_type).and_return(mime_type)
|
27
|
+
|
28
|
+
expect(file.content_type).to eq(mime_type)
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'permits overriding the default value' do
|
32
|
+
file.content_type = mime_type
|
33
|
+
|
34
|
+
expect(file.content_type).to eq(mime_type)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
data/spec/ftp_spec.rb
CHANGED
@@ -140,8 +140,7 @@ describe CarrierWave::Storage::FTP do
|
|
140
140
|
end
|
141
141
|
|
142
142
|
it "returns the content_type of the file" do
|
143
|
-
@stored.
|
144
|
-
@stored.content_type.should == 'some/type'
|
143
|
+
@stored.content_type.should == 'image/jpeg'
|
145
144
|
end
|
146
145
|
end
|
147
146
|
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'carrierwave/storage/sftp'
|
3
|
+
|
4
|
+
describe CarrierWave::Storage::SFTP::File do
|
5
|
+
let(:uploader) do
|
6
|
+
Class.new(CarrierWave::Uploader::Base) do
|
7
|
+
storage :sftp
|
8
|
+
end.tap do |u|
|
9
|
+
allow(u).to receive(:store_path).and_return('uploads/test.jpg')
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
let(:base) { CarrierWave::Storage::SFTP.new(uploader) }
|
14
|
+
|
15
|
+
let(:file) do
|
16
|
+
CarrierWave::Storage::SFTP::File.new(uploader, base, uploader.store_path)
|
17
|
+
end
|
18
|
+
|
19
|
+
let(:mime_type) { double('mime_type') }
|
20
|
+
|
21
|
+
describe '#content_type' do
|
22
|
+
it 'delegates to base file by default' do
|
23
|
+
sanitized_file = CarrierWave::SanitizedFile.new(file)
|
24
|
+
expect(CarrierWave::SanitizedFile).to receive(:new).with(file.path).
|
25
|
+
and_return(sanitized_file)
|
26
|
+
expect(sanitized_file).to receive(:content_type).and_return(mime_type)
|
27
|
+
|
28
|
+
expect(file.content_type).to eq(mime_type)
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'permits overriding the default value' do
|
32
|
+
file.content_type = mime_type
|
33
|
+
|
34
|
+
expect(file.content_type).to eq(mime_type)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
data/spec/sftp_spec.rb
CHANGED
@@ -102,8 +102,7 @@ describe CarrierWave::Storage::SFTP do
|
|
102
102
|
end
|
103
103
|
|
104
104
|
it "returns the content_type of the file" do
|
105
|
-
@stored.
|
106
|
-
@stored.content_type.should == 'some/type'
|
105
|
+
@stored.content_type.should == 'image/jpeg'
|
107
106
|
end
|
108
107
|
end
|
109
108
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: carrierwave-ftp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Luan Santos
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-03-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: carrierwave
|
@@ -104,8 +104,10 @@ files:
|
|
104
104
|
- lib/carrierwave/storage/ftp/ex_sftp.rb
|
105
105
|
- lib/carrierwave/storage/ftp/version.rb
|
106
106
|
- lib/carrierwave/storage/sftp.rb
|
107
|
+
- spec/ftp_file_spec.rb
|
107
108
|
- spec/ftp_spec.rb
|
108
109
|
- spec/ftp_tls_spec.rb
|
110
|
+
- spec/sftp_file_spec.rb
|
109
111
|
- spec/sftp_spec.rb
|
110
112
|
- spec/spec_helper.rb
|
111
113
|
homepage: https://github.com/luan/carrierwave-ftp
|
@@ -133,7 +135,9 @@ signing_key:
|
|
133
135
|
specification_version: 4
|
134
136
|
summary: FTP support for CarrierWave
|
135
137
|
test_files:
|
138
|
+
- spec/ftp_file_spec.rb
|
136
139
|
- spec/ftp_spec.rb
|
137
140
|
- spec/ftp_tls_spec.rb
|
141
|
+
- spec/sftp_file_spec.rb
|
138
142
|
- spec/sftp_spec.rb
|
139
143
|
- spec/spec_helper.rb
|