bg_s3uploadable 0.0.3 → 0.1.0
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/app/assets/javascripts/bg_s3uploadable/s3uploader.js.coffee +19 -5
- data/app/controllers/bg_s3uploadable/signed_urls_controller.rb +11 -1
- data/lib/bg_s3uploadable/engine.rb +3 -1
- data/lib/bg_s3uploadable/rails/routes.rb +14 -0
- data/lib/bg_s3uploadable/version.rb +1 -1
- metadata +3 -3
- data/config/routes.rb +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 81589c98ab0e24b703716206be1c5f03afe5c1ce
|
4
|
+
data.tar.gz: 42f79d71406f566fac22be2495cd801f9394583e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 075c97accca583c0e8205bf1129616b53c03b83c7323d127b0e597027ff0e2180ac3b88b6a60f34a898b7e2f1d6134f4ef170b0966da5198a7903dd442241185
|
7
|
+
data.tar.gz: 8a9ba8b067d4323c584402f21f497d73755aa8df1234fd21d3155729b55aa3f4cca569bca8f92eda2cec38ecb168c81a4604663f3e82231d13b48e9ac2f4720c
|
@@ -7,6 +7,12 @@ draganddrop = () ->
|
|
7
7
|
else
|
8
8
|
@draggable
|
9
9
|
|
10
|
+
window.s3uploaderMessages =
|
11
|
+
signed_url: {}
|
12
|
+
|
13
|
+
window.s3uploaderCallbacks =
|
14
|
+
finished: (form, key) ->
|
15
|
+
|
10
16
|
window.s3uploaderInstall = () ->
|
11
17
|
$('.file-upload').each () ->
|
12
18
|
form = $ this
|
@@ -51,6 +57,7 @@ window.s3uploaderInstall = () ->
|
|
51
57
|
data:
|
52
58
|
doc:
|
53
59
|
title: data.files[0].name
|
60
|
+
size: data.files[0].size
|
54
61
|
success: (signature) ->
|
55
62
|
data.formData =
|
56
63
|
key: signature.key
|
@@ -63,6 +70,14 @@ window.s3uploaderInstall = () ->
|
|
63
70
|
|
64
71
|
data.submit()
|
65
72
|
|
73
|
+
error: (jqXHR, textStatus, errorThrown) ->
|
74
|
+
response = jqXHR.responseJSON
|
75
|
+
reader.abort()
|
76
|
+
setImageURI()
|
77
|
+
|
78
|
+
alert window.s3uploaderMessages.signed_url[response.error_description]
|
79
|
+
document.location.reload()
|
80
|
+
|
66
81
|
send: (e, data) ->
|
67
82
|
form.find('.progress').fadeIn()
|
68
83
|
|
@@ -71,17 +86,16 @@ window.s3uploaderInstall = () ->
|
|
71
86
|
setProgress percent
|
72
87
|
|
73
88
|
fail: (e, data) ->
|
74
|
-
|
89
|
+
alert "The upload failed for an unspecified reason. Please check that the image is less than 30 megabytes, then try again."
|
90
|
+
document.location.reload()
|
75
91
|
|
76
92
|
success: (data) ->
|
77
93
|
key = $(data).find('Key').text()
|
78
94
|
$s3key_field.val key
|
79
95
|
|
80
|
-
# uri = "/s3/uploaded_image?key=#{key}"
|
81
|
-
# setImageURI uri
|
82
|
-
|
83
|
-
# form.parents('form').submit()
|
84
96
|
form.hide()
|
97
|
+
window.s3uploaderCallbacks.finished form, key
|
98
|
+
|
85
99
|
done: (e, data) ->
|
86
100
|
form.find('.progress').fadeOut 300, () ->
|
87
101
|
setProgress 0
|
@@ -6,7 +6,7 @@ module BgS3uploadable
|
|
6
6
|
render json: {
|
7
7
|
policy: policy,
|
8
8
|
signature: s3_upload_signature(policy),
|
9
|
-
key: "uploads/#{SecureRandom.uuid}/#{
|
9
|
+
key: "uploads/#{SecureRandom.uuid}/#{doc_params[:title]}",
|
10
10
|
success_action_redirect: "/",
|
11
11
|
upload_endpoint: "https://#{ENV['S3_BUCKET']}.s3.amazonaws.com",
|
12
12
|
:AWSAccessKeyID => ENV['AWS_ACCESS_KEY_ID'],
|
@@ -28,6 +28,12 @@ module BgS3uploadable
|
|
28
28
|
redirect_to presign.presign(:get, expires: 5.minutes.from_now.to_i, secure: true).to_s
|
29
29
|
end
|
30
30
|
|
31
|
+
protected
|
32
|
+
|
33
|
+
def s3uploadable_controller?
|
34
|
+
true
|
35
|
+
end
|
36
|
+
|
31
37
|
private
|
32
38
|
|
33
39
|
# generate the policy document that amazon is expecting.
|
@@ -56,5 +62,9 @@ module BgS3uploadable
|
|
56
62
|
)
|
57
63
|
).gsub(/\n/, '')
|
58
64
|
end
|
65
|
+
|
66
|
+
def doc_params
|
67
|
+
params.require(:doc).permit :title, :size
|
68
|
+
end
|
59
69
|
end
|
60
70
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module ActionDispatch::Routing
|
2
|
+
class Mapper
|
3
|
+
def bg_s3uploadable(options={})
|
4
|
+
controller = options[:controller] || "bg_s3uploadable/signed_urls"
|
5
|
+
|
6
|
+
scope path: "/s3", as: :s3 do
|
7
|
+
get '/signed_url', controller: controller, action: 'show'
|
8
|
+
get '/uploaded_image', controller: controller, action: 'uploaded_image'
|
9
|
+
get '/uploaded_image/*key', controller: controller, action: 'uploaded_image',
|
10
|
+
format: false, as: :uploaded_image_with_key
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bg_s3uploadable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Keitaroh Kobayashi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-01-
|
11
|
+
date: 2015-01-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -138,9 +138,9 @@ files:
|
|
138
138
|
- app/controllers/bg_s3uploadable/signed_urls_controller.rb
|
139
139
|
- app/jobs/bg_s3uploadable/uploader_job.rb
|
140
140
|
- bg_s3uploadable.gemspec
|
141
|
-
- config/routes.rb
|
142
141
|
- lib/bg_s3uploadable.rb
|
143
142
|
- lib/bg_s3uploadable/engine.rb
|
143
|
+
- lib/bg_s3uploadable/rails/routes.rb
|
144
144
|
- lib/bg_s3uploadable/uploadable.rb
|
145
145
|
- lib/bg_s3uploadable/version.rb
|
146
146
|
homepage: https://github.com/keichan34/bg_s3uploadable
|
data/config/routes.rb
DELETED