breadbox 1.1.1 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/lib/breadbox/s3_client.rb +5 -4
- data/lib/breadbox/version.rb +1 -1
- data/spec/breadbox/s3_client_spec.rb +9 -1
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: af6366ca6d82477de1f12bd73a9f73a5c365eedb
|
4
|
+
data.tar.gz: bfaa27461d1e9a566add2fba9620a1e5508d57e5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 423bd1ae34de4bd77727b7b730d9c6c1e7eaca6ce7fdeec42669d617abf7c6f7a086e91e6c9207fdf8870816357b90b5b0839a6fccdb71d0f084c751d73c1ce9
|
7
|
+
data.tar.gz: ed241327293a87d34209cdf6c1a1eb4102e8ae136f73c88f939df4d87649ba181380c2189b8b6464c9254ef6c82df03a448aae55284fff49588963e96bc814fa
|
data/README.md
CHANGED
@@ -83,6 +83,8 @@ end
|
|
83
83
|
folder `/`.
|
84
84
|
- `file`: The file object that you are uploading, ex: `file = File.open('./path-to-local-file').
|
85
85
|
- `cleanup`: defaults to `false`, but if you pass `true` - it will remove the local file after uploading.
|
86
|
+
- `public`: defaults to `false`. Pass `true` if you'd like to set the file permission level to world readable.
|
87
|
+
- `content_type`: S3 knows how to handle most file types, but occasionally, you may need to specify your own
|
86
88
|
|
87
89
|
```ruby
|
88
90
|
# to upload a file to [Dropbox Folder or S3 Bucket]/uploads/my-cool-file.jpg
|
data/lib/breadbox/s3_client.rb
CHANGED
@@ -12,11 +12,12 @@ module Breadbox
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def upload(options = {})
|
15
|
-
path
|
16
|
-
file
|
17
|
-
acl
|
15
|
+
path = options[:path]
|
16
|
+
file = options[:file]
|
17
|
+
acl = options[:public] ? :public_read : nil
|
18
|
+
content_type = options[:content_type]
|
18
19
|
filepath = filepath_from_paths_and_file(root_path, path, file)[1..-1]
|
19
|
-
result = s3_bucket_object.objects[filepath].write(file, acl: acl)
|
20
|
+
result = s3_bucket_object.objects[filepath].write(file, acl: acl, content_type: content_type)
|
20
21
|
|
21
22
|
if result
|
22
23
|
result.public_url.to_s
|
data/lib/breadbox/version.rb
CHANGED
@@ -78,11 +78,19 @@ module Breadbox
|
|
78
78
|
|
79
79
|
it "writes a file to an S3 Bucket Object" do
|
80
80
|
file = File.open("./tmp/new-file.jpg")
|
81
|
-
options = { acl: :public_read }
|
81
|
+
options = { acl: :public_read, content_type: nil }
|
82
82
|
expect_any_instance_of(AWS::S3::S3Object).to receive(:write)
|
83
83
|
.with(file, options)
|
84
84
|
client.upload(path: "/", file: file, public: true)
|
85
85
|
end
|
86
|
+
|
87
|
+
it "passes content-type parameter" do
|
88
|
+
file = File.open("./tmp/new-file.jpg")
|
89
|
+
options = { content_type: "image/jpeg", acl: nil }
|
90
|
+
expect_any_instance_of(AWS::S3::S3Object).to receive(:write)
|
91
|
+
.with(file, options)
|
92
|
+
client.upload(path: "/", file: file, content_type: "image/jpeg")
|
93
|
+
end
|
86
94
|
end
|
87
95
|
end
|
88
96
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: breadbox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nathaniel Watts
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-01-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dropbox-sdk
|
@@ -144,7 +144,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
144
144
|
version: '0'
|
145
145
|
requirements: []
|
146
146
|
rubyforge_project:
|
147
|
-
rubygems_version: 2.
|
147
|
+
rubygems_version: 2.4.5
|
148
148
|
signing_key:
|
149
149
|
specification_version: 4
|
150
150
|
summary: An interface for uploading to Dropbox or Amazon S3.
|
@@ -156,4 +156,3 @@ test_files:
|
|
156
156
|
- spec/breadbox/s3_client_spec.rb
|
157
157
|
- spec/breadbox_spec.rb
|
158
158
|
- spec/spec_helper.rb
|
159
|
-
has_rdoc:
|