checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- MDkwMzEwYjRhYjY4ZjQ3MmY1YWEzNmY2MmU2ODk3ODUzZWM3NjUxMw==
5
- data.tar.gz: !binary |-
6
- NzJlMDhjMWU4YTljNzhkOTU5ZTBkZDM5ZjZlMDUxNzEzMzRiZmVjNA==
7
- !binary "U0hBNTEy":
2
+ SHA1:
3
+ metadata.gz: f90bbc7145b4048c5c0bf8989a9d309d9cf455fb
4
+ data.tar.gz: 7aaf4fedd67424def3acb816a0f98f82e7fef748
5
+ SHA512:
6
+ metadata.gz: 561e3bd62e7c28a0e0d558b96bf76ed89e2f721578b36ab0963e1a069b383233918e946eebbd9be56ae8368f5d97838f99b11898296e081471f6ba617d9170ff
7
+ data.tar.gz: ad6833bf17aa8c103fa89f92acb03acf8b45494066102409a011734ae8c5c736415558342d9dd49ba28996bb15a98ca1f7c238b042069cfb86f24bc04fd69ba3
8
- metadata.gz: !binary |-
9
- OGZmNzljOWI4ODFjZjBkNDM4ZDBjNzlkNmEwMTRkMTFlMmI1YzUxMGJhM2U3
10
- ODViOTNhYjNiZjY5YWFiNmExY2NmNjQ3NWEzMzY3MmVlYjZjNDI0NWI3YjEz
11
- MWYzYjBjNTJiNDA3YzU1NTAyNTY3NWNkOGQxZjEwNDk5ZTljYzA=
12
- data.tar.gz: !binary |-
13
- ZDg5Y2ViMWVhNGZkNmM1NGYyMjkwYWRmZmUwNGVmOTZjNWNhNjA0MDIxYzc5
14
- ODNkNDFmZjYwMzU2MWVhMTQwOWRmNjliNWU4ZTdkMjMxODRjMjdiMzdlOGQz
15
- MWY0M2EyYTJlMWY3NTZmNjdkNzI1ZDhkMmYwNGNhNTgxZmM3NmE=
data/app/assets/javascripts/s3_direct_upload.js.coffee CHANGED
@@ -16,7 +16,6 @@ $.fn.S3Uploader = (options) ->
16
16
17
17
settings =
18
18
path: ''
19
- add: null
20
19
additional_data: null
21
20
remove_completed_progress_bar: true
22
21
progress_container: $uploadForm
@@ -34,33 +33,22 @@ $.fn.S3Uploader = (options) ->
34
33
35
34
add: (e, data) ->
36
35
current_files.push data
37
- file = data.files[0]
38
- settings.add(data)
36
+ if current_files.length == data.originalFiles.length
37
+ $uploadForm.trigger("s3_uploads_queued", [current_files])
39
38
40
39
progress: (e, data) ->
41
40
progress = parseInt(data.loaded / data.total * 100, 10)
42
41
data.context.find('.bar').css('width', progress + '%')
43
42
44
43
done: (e, data) ->
45
- completed_upload = (data, content) =>
46
- data.context.remove() if data.context && settings.remove_completed_progress_bar # remove progress bar
44
+ data.context.remove() if data.context && settings.remove_completed_progress_bar # remove progress bar
45
+ $uploadForm.trigger("s3_upload_complete", [data])
47
- $uploadForm.trigger("s3_upload_complete", [content])
48
46
49
- current_files.splice($.inArray(data, current_files), 1) # remove that element from the array
50
- if current_files.length == 0
51
- $(document).trigger("s3_uploads_complete")
47
+ current_files.splice($.inArray(data, current_files), 1) # remove that element from the array
48
+ if current_files.length == 0
49
+ $(document).trigger("s3_uploads_complete")
52
50
53
- content = build_content_object $uploadForm, data.files[0]
54
51
55
- #once an upload completes, post to the server designated in the "data-post" attribute of the s3_upload_form
56
- to = $uploadForm.data('post')
57
- content[$uploadForm.data('as')] = content.url
58
- $.post(to, content, completed_upload(data, content)).error(=> fail(data))
59
-
60
- fail: (e, data) ->
61
- content = build_content_object $uploadForm, data.files[0]
62
- content.error_thrown = data.errorThrown
63
- $uploadForm.trigger("s3_upload_failed", [content])
64
52
65
53
formData: (form) ->
66
54
data = form.serializeArray()
@@ -75,22 +63,6 @@ $.fn.S3Uploader = (options) ->
75
63
76
64
data
77
65
78
- build_content_object = ($uploadForm, file) ->
79
- domain = $uploadForm.attr('action')
80
-
81
- if !file.upload_path
82
- file.upload_path = $uploadForm.find('input[name=key]').val().replace('/${filename}', '')
83
-
84
- path = settings.path + file.upload_path
85
- content = {}
86
- content.url = domain + path + '/' + file.name
87
- content.filename = file.name
88
- content.filepath = path
89
- content.filesize = file.size if 'size' of file
90
- content.filetype = file.type if 'type' of file
91
- content.filerelativepath = file.relativePath if 'relativePath' of file
92
- content = $.extend content, settings.additional_data if settings.additional_data
93
- content
94
66
95
67
#public methods
96
68
@initialize = ->
data/app/assets/javascripts/s3_direct_upload.js.js CHANGED
@@ -1,10 +1,10 @@
1
- // Generated by CoffeeScript 1.3.3
1
+ // Generated by CoffeeScript 1.6.3
2
2
var $;
3
3
4
4
$ = jQuery;
5
5
6
6
$.fn.S3Uploader = function(options) {
7
- var $uploadForm, build_content_object, current_files, setUploadForm, settings;
7
+ var $uploadForm, current_files, setUploadForm, settings;
8
8
if (this.length > 1) {
9
9
this.each(function() {
10
10
return $(this).S3Uploader(options);
@@ -14,7 +14,6 @@ $.fn.S3Uploader = function(options) {
14
14
$uploadForm = this;
15
15
settings = {
16
16
path: '',
17
- add: null,
18
17
additional_data: null,
19
18
remove_completed_progress_bar: true,
20
19
progress_container: $uploadForm
@@ -27,10 +26,10 @@ $.fn.S3Uploader = function(options) {
27
26
return $uploadForm.trigger("s3_uploads_start", [e]);
28
27
},
29
28
add: function(e, data) {
30
- var file;
31
29
current_files.push(data);
32
- file = data.files[0];
33
- return settings.add(data);
30
+ if (current_files.length === data.originalFiles.length) {
31
+ return $uploadForm.trigger("s3_uploads_queued", [current_files]);
32
+ }
34
33
},
35
34
progress: function(e, data) {
36
35
var progress;
@@ -38,30 +37,14 @@ $.fn.S3Uploader = function(options) {
38
37
return data.context.find('.bar').css('width', progress + '%');
39
38
},
40
39
done: function(e, data) {
41
- var completed_upload, content, to,
42
- _this = this;
43
- completed_upload = function(data, content) {
44
- if (data.context && settings.remove_completed_progress_bar) {
45
- data.context.remove();
46
- }
47
- $uploadForm.trigger("s3_upload_complete", [content]);
48
- current_files.splice($.inArray(data, current_files), 1);
40
+ if (data.context && settings.remove_completed_progress_bar) {
41
+ data.context.remove();
42
+ }
43
+ $uploadForm.trigger("s3_upload_complete", [data]);
44
+ current_files.splice($.inArray(data, current_files), 1);
45
+ if (current_files.length === 0) {
46
+ return $(document).trigger("s3_uploads_complete");
47
+ }
49
- if (current_files.length === 0) {
50
- return $(document).trigger("s3_uploads_complete");
51
- }
52
- };
53
- content = build_content_object($uploadForm, data.files[0]);
54
- to = $uploadForm.data('post');
55
- content[$uploadForm.data('as')] = content.url;
56
- return $.post(to, content, completed_upload(data, content)).error(function() {
57
- return fail(data);
58
- });
59
- },
60
- fail: function(e, data) {
61
- var content;
62
- content = build_content_object($uploadForm, data.files[0]);
63
- content.error_thrown = data.errorThrown;
64
- return $uploadForm.trigger("s3_upload_failed", [content]);
65
48
},
66
49
formData: function(form) {
67
50
var data, fileType;
@@ -79,31 +62,6 @@ $.fn.S3Uploader = function(options) {
79
62
}
80
63
});
81
64
};
82
- build_content_object = function($uploadForm, file) {
83
- var content, domain, path;
84
- domain = $uploadForm.attr('action');
85
- if (!file.upload_path) {
86
- file.upload_path = $uploadForm.find('input[name=key]').val().replace('/${filename}', '');
87
- }
88
- path = settings.path + file.upload_path;
89
- content = {};
90
- content.url = domain + path + '/' + file.name;
91
- content.filename = file.name;
92
- content.filepath = path;
93
- if ('size' in file) {
94
- content.filesize = file.size;
95
- }
96
- if ('type' in file) {
97
- content.filetype = file.type;
98
- }
99
- if ('relativePath' in file) {
100
- content.filerelativepath = file.relativePath;
101
- }
102
- if (settings.additional_data) {
103
- content = $.extend(content, settings.additional_data);
104
- }
105
- return content;
106
- };
107
65
this.initialize = function() {
108
66
setUploadForm();
109
67
return this;
data/lib/s3_direct_upload/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
module S3DirectUpload
2
- VERSION = "0.0.13"
2
+ VERSION = "0.0.14"
3
3
end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
--- !ruby/object:Gem::Specification
2
2
name: actionverb_s3_direct_upload
3
3
version: !ruby/object:Gem::Version
4
- version: 0.0.13
4
+ version: 0.0.14
5
5
platform: ruby
6
6
authors:
7
7
- Wayne Hoover
8
8
autorequire:
9
9
bindir: bin
10
10
cert_chain: []
11
- date: 2013-05-19 00:00:00.000000000 Z
11
+ date: 2013-06-11 00:00:00.000000000 Z
12
12
dependencies:
13
13
- !ruby/object:Gem::Dependency
14
14
name: rails
@@ -74,14 +74,14 @@ extensions: []
74
74
extra_rdoc_files: []
75
75
files:
76
76
- lib/actionverb_s3_direct_upload.rb
77
- - lib/s3_direct_upload/config_aws.rb
77
+ - lib/s3_direct_upload.rb
78
- - lib/s3_direct_upload/engine.rb
79
78
- lib/s3_direct_upload/form_helper.rb
79
+ - lib/s3_direct_upload/engine.rb
80
80
- lib/s3_direct_upload/version.rb
81
- - lib/s3_direct_upload.rb
81
+ - lib/s3_direct_upload/config_aws.rb
82
- - app/assets/javascripts/s3_direct_upload.js.coffee
83
- - app/assets/javascripts/s3_direct_upload.js.js
84
82
- app/assets/stylesheets/s3_direct_upload_progress_bars.css.scss
83
+ - app/assets/javascripts/s3_direct_upload.js.js
84
+ - app/assets/javascripts/s3_direct_upload.js.coffee
85
85
- LICENSE
86
86
- README.md
87
87
homepage: ''
@@ -93,20 +93,19 @@ require_paths:
93
93
- lib
94
94
required_ruby_version: !ruby/object:Gem::Requirement
95
95
requirements:
96
- - - ! '>='
96
+ - - '>='
97
97
- !ruby/object:Gem::Version
98
98
version: '0'
99
99
required_rubygems_version: !ruby/object:Gem::Requirement
100
100
requirements:
101
- - - ! '>='
101
+ - - '>='
102
102
- !ruby/object:Gem::Version
103
103
version: '0'
104
104
requirements: []
105
105
rubyforge_project:
106
- rubygems_version: 2.0.3
106
+ rubygems_version: 2.0.0
107
107
signing_key:
108
108
specification_version: 4
109
109
summary: Gives a form helper for Rails which allows direct uploads to s3. Based on
110
110
RailsCast#383
111
111
test_files: []
112
- has_rdoc: