s3_file_field 1.0.6 → 1.0.7

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e4b6185b0069d80c746a0916f32fee06dcfbd202
4
- data.tar.gz: 3dbd305498f5eafcfba89c99e849b05b065616cd
3
+ metadata.gz: e91d0fe38036204121030961fcdbdecc3d1894e8
4
+ data.tar.gz: 65089c91fcc1692718f6398424e48c473124c638
5
5
  SHA512:
6
- metadata.gz: 8b4e772e179e15d398185eb209d538185392c110ed5cf8af600fe7087fe64e21dcae356d1d272546ae4ad5d58312c081d8d942768d157df65a8e42eef523176a
7
- data.tar.gz: ddef39dfbc33ab6a61c3387410263fb7d82b8cadbc9bf2aa312a28188497484dc39a7c4f3b462904277b389e37e9017fb799bf16e1ddead0f321e04a2996cc61
6
+ metadata.gz: a47af2e0ae5bc848109a16db1631dbd9a57eb75129e96fa74f7d12be6bbc2efd965646da4da014d126fe14ec1c48056be7601ded752ad4b9b81d1cfac3600f49
7
+ data.tar.gz: 6317d5350477e4f5fc340fc121cedb1103d4144c0149a0545e53c8c3365dd214e67856dc682791a4da4747cdd0ac3a3c1e84514cef17e6dfb3a57922dbb5eaef
data/README.md CHANGED
@@ -90,7 +90,7 @@ jQuery.ready ->
90
90
  done: (e, data) -> console.log(data.result.url)
91
91
  ```
92
92
 
93
- # Advanced usage
93
+ ## Advanced usage
94
94
 
95
95
  ```haml
96
96
  = form_for :user do |f|
@@ -34,12 +34,12 @@ jQuery.fn.S3FileField = (options) ->
34
34
  add = extractOption('add')
35
35
  done = extractOption('done')
36
36
  fail = extractOption('fail')
37
- formData = extractOption('formData')
37
+ extraFormData = extractOption('formData')
38
38
 
39
39
  delete options['paramName']
40
40
  delete options['singleFileUploads']
41
41
 
42
- finalFormData = undefined
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 $this, data.files[0], data.result
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
- finalFormData =
74
- key: $this.data('key').replace('{timestamp}', new Date().getTime()).replace('{unique_id}', @files[0].unique_id)
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(formData))
84
+ getFormData(finalFormData[unique_id]).concat(getFormData(extraFormData))
84
85
 
85
86
  jQuery.extend settings, options
86
87
 
87
- build_content_object = ($this, file, result) ->
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
@@ -1,3 +1,3 @@
1
1
  module S3FileField
2
- VERSION = "1.0.6"
2
+ VERSION = "1.0.7"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: s3_file_field
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.6
4
+ version: 1.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Stankiewicz