actionverb_s3_direct_upload 0.0.10 → 0.0.11
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MjhhMjNhMTU4ODk2Y2FiNTE4YWE0OTMwNzA4MTc5ZWYzYWZmZTEwZA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NjIwZWRiYWY3MzNjMTFiOGJjNWE4NmFiMzA4MGJkODBmZjY0ZjRiMg==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZTEzZjJmNDQ4ZGI2ZDIzOTA3NTc0ODIwMjkxMGVlOWYyNWM4Njg1MTk3MDI5
|
10
|
+
ZjQ0ODIzOGI1NTUxYjQyMTczM2RkOGM2ZTY3MWRkNGE2YmI1YWNhYmRkOTYz
|
11
|
+
NWUyNzZhOTVmYmFhZGJlMmQ2MTVhMWExZDVhZDFjMzllNDk1Zjc=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
N2ZjMjc0NDI4MWFjMzZiNGZlYTM3Y2RiYmNiZjgyZTA2ZTNiODI5YWNiNDIw
|
14
|
+
NWQ1YTZmN2ZiNzUzNWZiYzhiNDQzMjExZTUyYWQ5ZDVjZTI3ZTA2Nzk4ZjFm
|
15
|
+
NzM3Nzk2NmQyYzI4YzY4MDM4MGNlMTRiYmEzN2FlMDI1OWUwYjE=
|
@@ -11,16 +11,20 @@ module S3DirectUpload
|
|
11
11
|
|
12
12
|
class S3Uploader
|
13
13
|
def initialize(options)
|
14
|
+
@additional_headers = options[:additional_headers] || []
|
14
15
|
@options = options.reverse_merge(
|
15
16
|
aws_access_key_id: S3DirectUpload.config.access_key_id,
|
16
17
|
aws_secret_access_key: S3DirectUpload.config.secret_access_key,
|
17
18
|
bucket: S3DirectUpload.config.bucket,
|
18
19
|
acl: "public-read",
|
19
20
|
expiration: 10.hours.from_now.utc.iso8601,
|
20
|
-
max_file_size:
|
21
|
+
max_file_size: 64.gigabytes,
|
21
22
|
as: "file",
|
22
23
|
key: key
|
23
24
|
)
|
25
|
+
@additional_headers.each do |header|
|
26
|
+
@options[header[0]]=@options[header[1]]
|
27
|
+
end
|
24
28
|
end
|
25
29
|
|
26
30
|
def form_options
|
@@ -71,7 +75,7 @@ module S3DirectUpload
|
|
71
75
|
{bucket: @options[:bucket]},
|
72
76
|
{acl: @options[:acl]},
|
73
77
|
{success_action_status: "201"}
|
74
|
-
]
|
78
|
+
].concat(@additional_headers)
|
75
79
|
}
|
76
80
|
end
|
77
81
|
|
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.
|
4
|
+
version: 0.0.11
|
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-04-
|
11
|
+
date: 2013-04-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -74,14 +74,13 @@ extensions: []
|
|
74
74
|
extra_rdoc_files: []
|
75
75
|
files:
|
76
76
|
- lib/actionverb_s3_direct_upload.rb
|
77
|
-
- lib/s3_direct_upload
|
78
|
-
- lib/s3_direct_upload/engine.rb
|
77
|
+
- lib/s3_direct_upload.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
|
82
|
-
- app/assets/javascripts/s3_direct_upload.js.coffee
|
83
|
-
- app/assets/javascripts/s3_direct_upload.js.js
|
81
|
+
- lib/s3_direct_upload/config_aws.rb
|
84
82
|
- app/assets/stylesheets/s3_direct_upload_progress_bars.css.scss
|
83
|
+
- app/assets/javascripts/s3_direct_upload.js.coffee
|
85
84
|
- LICENSE
|
86
85
|
- README.md
|
87
86
|
homepage: ''
|
@@ -1,121 +0,0 @@
|
|
1
|
-
// Generated by CoffeeScript 1.3.3
|
2
|
-
var $;
|
3
|
-
|
4
|
-
$ = jQuery;
|
5
|
-
|
6
|
-
$.fn.S3Uploader = function(options) {
|
7
|
-
var $uploadForm, build_content_object, current_files, setUploadForm, settings;
|
8
|
-
if (this.length > 1) {
|
9
|
-
this.each(function() {
|
10
|
-
return $(this).S3Uploader(options);
|
11
|
-
});
|
12
|
-
return this;
|
13
|
-
}
|
14
|
-
$uploadForm = this;
|
15
|
-
settings = {
|
16
|
-
path: '',
|
17
|
-
additional_data: null,
|
18
|
-
before_add: null,
|
19
|
-
remove_completed_progress_bar: true,
|
20
|
-
progress_container: $uploadForm
|
21
|
-
};
|
22
|
-
$.extend(settings, options);
|
23
|
-
current_files = [];
|
24
|
-
setUploadForm = function() {
|
25
|
-
return $uploadForm.fileupload({
|
26
|
-
start: function(e) {
|
27
|
-
return $uploadForm.trigger("s3_uploads_start", [e]);
|
28
|
-
},
|
29
|
-
add: function(e, data) {
|
30
|
-
var file;
|
31
|
-
current_files.push(data);
|
32
|
-
file = data.files[0];
|
33
|
-
if (!(settings.before_add && !settings.before_add(data))) {
|
34
|
-
if ($('#template-upload').length > 0) {
|
35
|
-
data.context = $(tmpl("template-upload", file));
|
36
|
-
}
|
37
|
-
settings['progress_container'].append(data.context);
|
38
|
-
return data.submit();
|
39
|
-
}
|
40
|
-
},
|
41
|
-
progress: function(e, data) {
|
42
|
-
var progress;
|
43
|
-
if (data.context) {
|
44
|
-
progress = parseInt(data.loaded / data.total * 100, 10);
|
45
|
-
return data.context.find('.bar').css('width', progress + '%');
|
46
|
-
}
|
47
|
-
},
|
48
|
-
done: function(e, data) {
|
49
|
-
var content, to;
|
50
|
-
content = build_content_object($uploadForm, data.files[0]);
|
51
|
-
to = $uploadForm.data('post');
|
52
|
-
if (to) {
|
53
|
-
content[$uploadForm.data('as')] = content.url;
|
54
|
-
$.post(to, content);
|
55
|
-
}
|
56
|
-
if (data.context && settings.remove_completed_progress_bar) {
|
57
|
-
data.context.remove();
|
58
|
-
}
|
59
|
-
$uploadForm.trigger("s3_upload_complete", [content]);
|
60
|
-
current_files.splice($.inArray(data, current_files), 1);
|
61
|
-
if (current_files.length === 0) {
|
62
|
-
return $(document).trigger("s3_uploads_complete");
|
63
|
-
}
|
64
|
-
},
|
65
|
-
fail: function(e, data) {
|
66
|
-
var content;
|
67
|
-
content = build_content_object($uploadForm, data.files[0]);
|
68
|
-
content.error_thrown = data.errorThrown;
|
69
|
-
return $uploadForm.trigger("s3_upload_failed", [content]);
|
70
|
-
},
|
71
|
-
formData: function(form) {
|
72
|
-
var data, fileType;
|
73
|
-
data = form.serializeArray();
|
74
|
-
fileType = "";
|
75
|
-
if ("type" in this.files[0]) {
|
76
|
-
fileType = this.files[0].type;
|
77
|
-
}
|
78
|
-
data.push({
|
79
|
-
name: "Content-Type",
|
80
|
-
value: fileType
|
81
|
-
});
|
82
|
-
data[1].value = settings.path + data[1].value;
|
83
|
-
return data;
|
84
|
-
}
|
85
|
-
});
|
86
|
-
};
|
87
|
-
build_content_object = function($uploadForm, file) {
|
88
|
-
var content, domain, path;
|
89
|
-
domain = $uploadForm.attr('action');
|
90
|
-
path = settings.path + $uploadForm.find('input[name=key]').val().replace('/${filename}', '');
|
91
|
-
content = {};
|
92
|
-
content.url = domain + path + '/' + file.name;
|
93
|
-
content.filename = file.name;
|
94
|
-
content.filepath = path;
|
95
|
-
if ('size' in file) {
|
96
|
-
content.filesize = file.size;
|
97
|
-
}
|
98
|
-
if ('type' in file) {
|
99
|
-
content.filetype = file.type;
|
100
|
-
}
|
101
|
-
if ('relativePath' in file) {
|
102
|
-
content.filerelativepath = file.relativePath;
|
103
|
-
}
|
104
|
-
if (settings.additional_data) {
|
105
|
-
content = $.extend(content, settings.additional_data);
|
106
|
-
}
|
107
|
-
console.log(content);
|
108
|
-
return content;
|
109
|
-
};
|
110
|
-
this.initialize = function() {
|
111
|
-
setUploadForm();
|
112
|
-
return this;
|
113
|
-
};
|
114
|
-
this.path = function(new_path) {
|
115
|
-
return settings.path = new_path;
|
116
|
-
};
|
117
|
-
this.additional_data = function(new_data) {
|
118
|
-
return settings.additional_data = new_data;
|
119
|
-
};
|
120
|
-
return this.initialize();
|
121
|
-
};
|