qiniu_direct_uploader 0.0.4 → 0.0.5
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c9279d8ae2d3be7053661b01faebde1d86a8f328
|
4
|
+
data.tar.gz: 8065ce19db3050fe11d618166da923715109385a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aff2043144df9708abf37df382d37b0a92c8d0c8209cdd67d0b0911262a359d6313bb0a698249a3742f3e3d4458dbef0a907fe568f7420f0945bd48f11f1e616
|
7
|
+
data.tar.gz: 5e1b148b0fcfce0b523e18d4ee725dd17c481e4256159afb9808a9019925919611ca2b5bf4dc5ab74b1438d6122eb4019c4ad84060e100fb1e4e8ef5131f726c
|
data/README.md
CHANGED
@@ -25,7 +25,7 @@ see the example project: https://github.com/huobazi/qiniu-direct-upload-example
|
|
25
25
|
<%= qiniu_uploader_form callback_url: items_path,
|
26
26
|
bucket: 'spec-test',
|
27
27
|
id: "photograph-uploader",
|
28
|
-
|
28
|
+
save_key: "uploads/items/$(year)/$(mon)/$(day)/$(etag)/$(fname)",
|
29
29
|
custom_fields: {aaa:1,bbb:2},
|
30
30
|
progress_bar_id: 'progress-bar',
|
31
31
|
drop_paste_zone_id: 'dropzone' do %>
|
@@ -46,23 +46,12 @@ $.fn.QiniuUploader = (options) ->
|
|
46
46
|
form.submit() for form in formsForSubmit
|
47
47
|
false
|
48
48
|
|
49
|
-
generateRandomString= (length) ->
|
50
|
-
chars = "abcdefghiklmno0123456789pqrstuvwxyz"
|
51
|
-
text = ""
|
52
|
-
i = 0
|
53
|
-
while i < length
|
54
|
-
randomPoz = Math.floor(Math.random() * chars.length)
|
55
|
-
text += chars.substring(randomPoz, randomPoz + 1)
|
56
|
-
i++
|
57
|
-
text
|
58
|
-
|
59
49
|
setUploadForm = ->
|
60
50
|
inner_settings =
|
61
51
|
dropZone: dropPasteZone
|
62
52
|
pasteZone: dropPasteZone
|
63
53
|
add: (e, data) ->
|
64
54
|
file = data.files[0]
|
65
|
-
file.uniqueId = generateRandomString(10) + Math.random().toString(36).substr(2,12)
|
66
55
|
|
67
56
|
unless settings.onFilesAdd and not settings.onFilesAdd(file)
|
68
57
|
currentFiles.push data
|
@@ -117,9 +106,6 @@ $.fn.QiniuUploader = (options) ->
|
|
117
106
|
data = form.serializeArray()
|
118
107
|
|
119
108
|
key = $uploadForm.data("key")
|
120
|
-
.replace('{timestamp}', new Date().getTime())
|
121
|
-
.replace('{unique-id}', @files[0].uniqueId)
|
122
|
-
.replace('{filename}', @files[0].name)
|
123
109
|
|
124
110
|
# substitute upload timestamp and uniqueId into key
|
125
111
|
keyField = $.grep data, (n) ->
|
@@ -31,23 +31,19 @@ module QiniuDirectUploader
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def fields
|
34
|
-
{
|
35
|
-
|
36
|
-
|
37
|
-
|
34
|
+
the_fields = {}
|
35
|
+
the_fields[:token] = @options[:token] || token
|
36
|
+
the_fields[:key] = @options[:key] if @options[:key]
|
37
|
+
the_fields
|
38
38
|
end
|
39
39
|
|
40
40
|
def custom_fields
|
41
41
|
@options[:custom_fields]
|
42
42
|
end
|
43
43
|
|
44
|
-
def
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
def key
|
49
|
-
return @options[:key] if @options[:key]
|
50
|
-
return default_key
|
44
|
+
def save_key
|
45
|
+
return @options[:save_key] if @options[:save_key]
|
46
|
+
"uploads/$(year)/$(mon)/$(day)/$(etag)/$(fname)"
|
51
47
|
end
|
52
48
|
|
53
49
|
def action
|
@@ -77,9 +73,10 @@ module QiniuDirectUploader
|
|
77
73
|
end
|
78
74
|
|
79
75
|
def token
|
80
|
-
put_policy = Qiniu::Auth::PutPolicy.new( @options[:bucket],
|
76
|
+
put_policy = Qiniu::Auth::PutPolicy.new( @options[:bucket], @options[:key], @options[:expires_in], nil )
|
81
77
|
put_policy.return_body = return_body
|
82
|
-
put_policy.
|
78
|
+
put_policy.save_key = save_key
|
79
|
+
put_policy.end_user = @options[:customer] if @options[:customer]
|
83
80
|
|
84
81
|
Qiniu::Auth.generate_uptoken(put_policy)
|
85
82
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: qiniu_direct_uploader
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marble Wu
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-11-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|