s3_direct_upload 0.1.3 → 0.1.4
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 -2
- data/app/assets/javascripts/s3_direct_upload.js.coffee +18 -4
- data/lib/s3_direct_upload/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2d7df44d91a8abeebc48b92b35a0d6724f599449
|
4
|
+
data.tar.gz: 2a792e6395b81ce538463552b3fd7f4a8807c1a5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5db1d43f6016f4bead8f4197213a75fdab4178cf55bb25a663d165c7021d3b1094814ab7bb7c29577565aa3720c2950dec02b77784c8a6cc846f6ffa7dd28f3f
|
7
|
+
data.tar.gz: cf6dcce917f14bd06601e94d78ef75232006345220b044f2027fdab5d6ca7243fdcfd28698d57d6e5f1b20010a0ef9de57a3039a87287513be329127b1c073c0
|
data/README.md
CHANGED
@@ -18,8 +18,8 @@ S3DirectUpload.config do |c|
|
|
18
18
|
c.access_key_id = "" # your access key id
|
19
19
|
c.secret_access_key = "" # your secret access key
|
20
20
|
c.bucket = "" # your bucket name
|
21
|
-
c.region =
|
22
|
-
c.url =
|
21
|
+
c.region = nil # region prefix of your bucket url (optional), eg. "s3-eu-west-1"
|
22
|
+
c.url = nil # S3 API endpoint (optional), eg. "https://#{c.bucket}.s3.amazonaws.com/"
|
23
23
|
end
|
24
24
|
```
|
25
25
|
|
@@ -22,6 +22,7 @@ $.fn.S3Uploader = (options) ->
|
|
22
22
|
remove_failed_progress_bar: false
|
23
23
|
progress_bar_target: null
|
24
24
|
click_submit_target: null
|
25
|
+
allow_multiple_files: true
|
25
26
|
|
26
27
|
$.extend settings, options
|
27
28
|
|
@@ -36,15 +37,19 @@ $.fn.S3Uploader = (options) ->
|
|
36
37
|
$uploadForm.fileupload
|
37
38
|
|
38
39
|
add: (e, data) ->
|
40
|
+
$uploadForm.trigger("file_added", [e,data])
|
41
|
+
|
39
42
|
file = data.files[0]
|
40
43
|
file.unique_id = Math.random().toString(36).substr(2,16)
|
41
44
|
|
42
45
|
unless settings.before_add and not settings.before_add(file)
|
43
|
-
current_files.push data
|
44
46
|
data.context = $($.trim(tmpl("template-upload", file))) if $('#template-upload').length > 0
|
45
47
|
$(data.context).appendTo(settings.progress_bar_target || $uploadForm)
|
46
48
|
if settings.click_submit_target
|
47
|
-
|
49
|
+
if settings.allow_multiple_files
|
50
|
+
forms_for_submit.push data
|
51
|
+
else
|
52
|
+
forms_for_submit = [data]
|
48
53
|
else
|
49
54
|
data.submit()
|
50
55
|
|
@@ -94,9 +99,15 @@ $.fn.S3Uploader = (options) ->
|
|
94
99
|
name: "content-type"
|
95
100
|
value: fileType
|
96
101
|
|
102
|
+
key = $uploadForm.data("key").replace('{timestamp}', new Date().getTime()).replace('{unique_id}', @files[0].unique_id)
|
103
|
+
|
97
104
|
# substitute upload timestamp and unique_id into key
|
98
|
-
key = data[1].value.replace('{timestamp}', new Date().getTime()).replace('{unique_id}', @files[0].unique_id)
|
99
105
|
data[1].value = settings.path + key
|
106
|
+
|
107
|
+
# IE <= 9 doesn't have XHR2 hence it can't use formData
|
108
|
+
# replace 'key' field to submit form
|
109
|
+
unless 'FormData' of window
|
110
|
+
$uploadForm.find("input[name='key']").val(settings.path + key)
|
100
111
|
data
|
101
112
|
|
102
113
|
build_content_object = ($uploadForm, file, result) ->
|
@@ -106,7 +117,7 @@ $.fn.S3Uploader = (options) ->
|
|
106
117
|
content.filepath = $('<a />').attr('href', content.url)[0].pathname
|
107
118
|
else # IE <= 9 return a null result object so we use the file object instead
|
108
119
|
domain = $uploadForm.attr('action')
|
109
|
-
content.filepath =
|
120
|
+
content.filepath = $uploadForm.find('input[name=key]').val().replace('/${filename}', '')
|
110
121
|
content.url = domain + content.filepath + '/' + encodeURIComponent(file.name)
|
111
122
|
|
112
123
|
content.filename = file.name
|
@@ -126,6 +137,9 @@ $.fn.S3Uploader = (options) ->
|
|
126
137
|
|
127
138
|
#public methods
|
128
139
|
@initialize = ->
|
140
|
+
# Save key for IE9 Fix
|
141
|
+
$uploadForm.data("key", $uploadForm.find("input[name='key']").val())
|
142
|
+
|
129
143
|
setUploadForm()
|
130
144
|
this
|
131
145
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: s3_direct_upload
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
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-
|
11
|
+
date: 2013-05-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -103,7 +103,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
103
103
|
version: '0'
|
104
104
|
requirements: []
|
105
105
|
rubyforge_project:
|
106
|
-
rubygems_version: 2.0.
|
106
|
+
rubygems_version: 2.0.2
|
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
|