s3_multipart 0.0.2 → 0.0.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.
- data/Gemfile.lock +3 -3
- data/app/controllers/s3_multipart/uploads_controller.rb +2 -1
- data/app/models/s3_multipart/upload.rb +1 -0
- data/lib/s3_multipart/version.rb +1 -1
- data/lib/s3_multipart.rb +21 -10
- data/spec/internal/app/assets/javascripts/application.js +3 -0
- data/spec/internal/app/controllers/pages_controller.rb +7 -3
- data/spec/internal/db/combustion_test.sqlite3 +0 -0
- metadata +2 -3
- data/s3_multipart-0.0.1.gem +0 -0
data/Gemfile.lock
CHANGED
@@ -5,6 +5,7 @@ module S3Multipart
|
|
5
5
|
response = Upload.initiate(params)
|
6
6
|
upload = Upload.create(key: response["key"], upload_id: response["upload_id"], name: response["name"])
|
7
7
|
response["id"] = upload["id"]
|
8
|
+
upload.on_begin if upload.respond_to?(:on_begin)
|
8
9
|
rescue
|
9
10
|
response = {error: 'There was an error initiating the upload'}
|
10
11
|
ensure
|
@@ -45,7 +46,7 @@ module S3Multipart
|
|
45
46
|
response = Upload.complete(params)
|
46
47
|
upload = Upload.find_by_upload_id(params[:upload_id])
|
47
48
|
upload.update_attributes(location: response[:location])
|
48
|
-
upload.on_complete
|
49
|
+
upload.on_complete if upload.respond_to?(:on_complete)
|
49
50
|
rescue
|
50
51
|
response = {error: 'There was an error completing the upload'}
|
51
52
|
ensure
|
data/lib/s3_multipart/version.rb
CHANGED
data/lib/s3_multipart.rb
CHANGED
@@ -15,6 +15,7 @@ module S3Multipart
|
|
15
15
|
# config.s3_secret_key = ''
|
16
16
|
# config.bucket_name = ''
|
17
17
|
# end
|
18
|
+
|
18
19
|
def configure(&block)
|
19
20
|
S3Multipart::Uploader::Config.configure(block)
|
20
21
|
end
|
@@ -27,18 +28,28 @@ module S3Multipart
|
|
27
28
|
|
28
29
|
module ActionControllerHelpers
|
29
30
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
self.on_complete_callback = block
|
38
|
-
def on_complete
|
39
|
-
Upload.on_complete_callback.call(self)
|
31
|
+
module AttachUploader
|
32
|
+
def self.on_begin(&block)
|
33
|
+
S3Multipart::Upload.class_eval do
|
34
|
+
self.on_begin_callback = block
|
35
|
+
def on_begin
|
36
|
+
Upload.on_begin_callback.call(self)
|
37
|
+
end
|
40
38
|
end
|
41
39
|
end
|
40
|
+
|
41
|
+
def self.on_complete(&block)
|
42
|
+
S3Multipart::Upload.class_eval do
|
43
|
+
self.on_complete_callback = block
|
44
|
+
def on_complete
|
45
|
+
Upload.on_complete_callback.call(self)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def attach_uploader
|
52
|
+
return AttachUploader
|
42
53
|
end
|
43
54
|
|
44
55
|
end
|
@@ -19,6 +19,9 @@ $(function() {
|
|
19
19
|
window.SS3MP = new window.S3MP({
|
20
20
|
bucket: 'bitcast-bucket',
|
21
21
|
fileSelector: "#uploader",
|
22
|
+
onStart: function(num) {
|
23
|
+
console.log("File "+num+" has started uploading")
|
24
|
+
},
|
22
25
|
onComplete: function(num) {
|
23
26
|
console.log("File "+num+" successfully uploaded")
|
24
27
|
},
|
@@ -1,9 +1,13 @@
|
|
1
1
|
class PagesController < ApplicationController
|
2
2
|
|
3
3
|
def upload
|
4
|
-
|
5
|
-
|
4
|
+
upload = attach_uploader
|
5
|
+
upload.on_begin do |upload|
|
6
|
+
upload.update_attributes(name: "begun")
|
7
|
+
end
|
8
|
+
upload.on_complete do |upload|
|
9
|
+
upload.update_attributes(name: "completed")
|
6
10
|
end
|
7
11
|
end
|
8
|
-
|
12
|
+
|
9
13
|
end
|
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: s3_multipart
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-01-
|
12
|
+
date: 2013-01-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: uuid
|
@@ -166,7 +166,6 @@ files:
|
|
166
166
|
- lib/s3_multipart/uploader.rb
|
167
167
|
- lib/s3_multipart/uploader/config.rb
|
168
168
|
- lib/s3_multipart/version.rb
|
169
|
-
- s3_multipart-0.0.1.gem
|
170
169
|
- s3_multipart.gemspec
|
171
170
|
- spec/integration/uploads_controller_spec.rb
|
172
171
|
- spec/internal/app/assets/javascripts/application.js
|
data/s3_multipart-0.0.1.gem
DELETED
Binary file
|