s3_file_field 1.0.6 → 1.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/app/assets/javascripts/s3_file_field.js.coffee +9 -8
- data/lib/s3_file_field/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e91d0fe38036204121030961fcdbdecc3d1894e8
|
4
|
+
data.tar.gz: 65089c91fcc1692718f6398424e48c473124c638
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a47af2e0ae5bc848109a16db1631dbd9a57eb75129e96fa74f7d12be6bbc2efd965646da4da014d126fe14ec1c48056be7601ded752ad4b9b81d1cfac3600f49
|
7
|
+
data.tar.gz: 6317d5350477e4f5fc340fc121cedb1103d4144c0149a0545e53c8c3365dd214e67856dc682791a4da4747cdd0ac3a3c1e84514cef17e6dfb3a57922dbb5eaef
|
data/README.md
CHANGED
@@ -34,12 +34,12 @@ jQuery.fn.S3FileField = (options) ->
|
|
34
34
|
add = extractOption('add')
|
35
35
|
done = extractOption('done')
|
36
36
|
fail = extractOption('fail')
|
37
|
-
|
37
|
+
extraFormData = extractOption('formData')
|
38
38
|
|
39
39
|
delete options['paramName']
|
40
40
|
delete options['singleFileUploads']
|
41
41
|
|
42
|
-
finalFormData =
|
42
|
+
finalFormData = {}
|
43
43
|
|
44
44
|
settings =
|
45
45
|
# File input name must be "file"
|
@@ -63,15 +63,16 @@ jQuery.fn.S3FileField = (options) ->
|
|
63
63
|
if add? then add(e, data) else data.submit()
|
64
64
|
|
65
65
|
done: (e, data) ->
|
66
|
-
data.result = build_content_object
|
66
|
+
data.result = build_content_object data.files[0]
|
67
67
|
done(e, data) if done?
|
68
68
|
|
69
69
|
fail: (e, data) ->
|
70
70
|
fail(e, data) if fail?
|
71
71
|
|
72
72
|
formData: (form) ->
|
73
|
-
|
74
|
-
|
73
|
+
unique_id = @files[0].unique_id
|
74
|
+
finalFormData[unique_id] =
|
75
|
+
key: $this.data('key').replace('{timestamp}', new Date().getTime()).replace('{unique_id}', unique_id)
|
75
76
|
'Content-Type': @files[0].type
|
76
77
|
acl: $this.data('acl')
|
77
78
|
'AWSAccessKeyId': $this.data('aws-access-key-id')
|
@@ -80,14 +81,14 @@ jQuery.fn.S3FileField = (options) ->
|
|
80
81
|
success_action_status: "201"
|
81
82
|
'X-Requested-With': 'xhr'
|
82
83
|
|
83
|
-
getFormData(finalFormData).concat(getFormData(
|
84
|
+
getFormData(finalFormData[unique_id]).concat(getFormData(extraFormData))
|
84
85
|
|
85
86
|
jQuery.extend settings, options
|
86
87
|
|
87
|
-
build_content_object = (
|
88
|
+
build_content_object = (file) ->
|
88
89
|
domain = settings.url.replace(/\/+$/, '').replace(/^(https?:)?/, 'https:')
|
89
90
|
content = {}
|
90
|
-
content.filepath = finalFormData['key'].replace('/${filename}', '')
|
91
|
+
content.filepath = finalFormData[file.unique_id]['key'].replace('/${filename}', '')
|
91
92
|
content.url = domain + '/' + content.filepath + '/' + file.name
|
92
93
|
content.filename = file.name
|
93
94
|
content.filesize = file.size if 'size' of file
|