mongoid-direct-s3-upload 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +2 -3
- data/app/controllers/s3_relay/uploads_controller.rb +5 -15
- data/app/models/s3_relay/upload.rb +2 -2
- data/lib/s3_relay/model.rb +2 -1
- data/lib/s3_relay/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1e0d2641b4ce3a70b19f1eb4ca23dfbcc3363052
|
4
|
+
data.tar.gz: e44ee934851643232aca8a968beba504c2d883af
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: acef0474e52f116a3e407696dc8db7fcf58182a4a9904e4b22c4302c252c7ff1620610ed2811a612d2745b129354a5798b970a6f29158549b3164702138fbef6
|
7
|
+
data.tar.gz: 8544fb25b876bb031084308f05956afe623a7ed8d4704bed3cd6e85dbe3678092934f7a468be025942738dd6fdbe1814b07d1746f62e52c8eb90761b3a4d8aff
|
data/README.md
CHANGED
@@ -85,7 +85,6 @@ to learn how to lock it down further.
|
|
85
85
|
## Installation
|
86
86
|
|
87
87
|
* Add `gem "mongoid-direct-s3-upload"` to your Gemfile and run `bundle`.
|
88
|
-
* Add migrations to your app with `rake s3_relay:install:migrations db:migrate`.
|
89
88
|
* Add `mount S3Relay::Engine => "/s3_relay"` to the top of your routes file.
|
90
89
|
* Add `require s3_relay` to your JavaScript manifest.
|
91
90
|
* [Optional] Add `require s3_relay` to your Style Sheet manifest.
|
@@ -238,11 +237,11 @@ end
|
|
238
237
|
|
239
238
|
## Contributing
|
240
239
|
|
241
|
-
1. [Fork it](https://github.com/
|
240
|
+
1. [Fork it](https://github.com/hartator/mongoid-direct-s3-upload/fork)
|
242
241
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
243
242
|
3. Commit your changes (`git commit -am 'Added some feature'`)
|
244
243
|
4. Push to the branch (`git push origin my-new-feature`)
|
245
|
-
5. [Create a Pull Request](https://github.com/
|
244
|
+
5. [Create a Pull Request](https://github.com/hartator/mongoid-direct-s3-upload/pull/new)
|
246
245
|
|
247
246
|
## License
|
248
247
|
|
@@ -15,7 +15,7 @@ class S3Relay::UploadsController < ApplicationController
|
|
15
15
|
private_url: @upload.private_url,
|
16
16
|
parent_type: @upload.parent_type,
|
17
17
|
parent_id: @upload.parent_id,
|
18
|
-
user_id: user_attrs[:user_id]
|
18
|
+
user_id: BSON::ObjectId(user_attrs[:user_id])
|
19
19
|
}
|
20
20
|
render json: data, status: 201
|
21
21
|
else
|
@@ -32,20 +32,10 @@ class S3Relay::UploadsController < ApplicationController
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def parent_attrs
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
parent = type.constantize.find(id)
|
40
|
-
|
41
|
-
begin
|
42
|
-
public_send(
|
43
|
-
"#{type.underscore.downcase}_#{params[:association]}_params",
|
44
|
-
parent
|
45
|
-
)
|
46
|
-
rescue NoMethodError
|
47
|
-
{ parent: parent }
|
48
|
-
end
|
35
|
+
{
|
36
|
+
parent_type: params[:parent_type].try(:classify),
|
37
|
+
parent_id: BSON::ObjectId(params[:parent_id])
|
38
|
+
}
|
49
39
|
end
|
50
40
|
|
51
41
|
def upload_attrs
|
@@ -4,9 +4,9 @@ module S3Relay
|
|
4
4
|
include Mongoid::Document
|
5
5
|
|
6
6
|
field :uuid
|
7
|
-
field :user_id, type:
|
7
|
+
field :user_id, type: BSON::ObjectId
|
8
8
|
field :parent_type, type: String
|
9
|
-
field :parent_id, type:
|
9
|
+
field :parent_id, type: BSON::ObjectId
|
10
10
|
field :upload_type, type: String
|
11
11
|
field :filename, type: String
|
12
12
|
field :content_type, type: String
|
data/lib/s3_relay/model.rb
CHANGED
@@ -2,6 +2,7 @@ module S3Relay
|
|
2
2
|
module Model
|
3
3
|
|
4
4
|
def s3_relay(attribute, has_many=false)
|
5
|
+
|
5
6
|
upload_type = attribute.to_s.classify
|
6
7
|
|
7
8
|
if has_many
|
@@ -13,7 +14,7 @@ module S3Relay
|
|
13
14
|
parent_type: self.class.to_s,
|
14
15
|
parent_id: self.id,
|
15
16
|
upload_type: upload_type
|
16
|
-
)
|
17
|
+
).to_a
|
17
18
|
end
|
18
19
|
else
|
19
20
|
has_one attribute, as: :parent, class_name: "S3Relay::Upload"
|
data/lib/s3_relay/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongoid-direct-s3-upload
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- hartator
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-06-
|
11
|
+
date: 2017-06-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: coffee-rails
|