uploadbox 0.0.9 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +38 -6
- data/app/assets/javascripts/_image_uploader.coffee +21 -3
- data/app/controllers/uploadbox/images_controller.rb +6 -2
- data/lib/generators/uploadbox/image/templates/migrate/create_images.rb +1 -1
- data/lib/uploadbox.rb +1 -0
- data/lib/uploadbox/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: f836cae407afd0efd7deeb07384addf19e9b9dce
|
4
|
+
data.tar.gz: 53ad4ff8b967f0b9e7d2345ccb70b0e0165a07db
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 92d197f8f76b8d9dd57e436e6ec09eb7d3107aa02666e7e2f80d88c6bc6c824cb54e550f31fca1c4fcf6072bbfbcc89a8c07f4045d7b5b30192e97d4a83634a7
|
7
|
+
data.tar.gz: 0c7c864ef01588ca0ccb7722112454d9ac0ef99a936a6c2a1c4d92ee233ac1d69583a848b7006220b9bd580decfe771fb98d2dd1610439467af8d9737fa2aeea
|
data/README.md
CHANGED
@@ -33,14 +33,27 @@ Migrate database
|
|
33
33
|
rake db:migrate
|
34
34
|
```
|
35
35
|
|
36
|
-
Create a bucket on S3
|
36
|
+
Create a development bucket on S3
|
37
37
|
|
38
38
|
Set environmet variables
|
39
39
|
```
|
40
40
|
S3_KEY=AAAA123BBBB
|
41
41
|
S3_SECRET=abc123ABcEffgee122
|
42
|
-
S3_REGION=
|
43
|
-
S3_BUCKET=uploads
|
42
|
+
S3_REGION=us-east-1
|
43
|
+
S3_BUCKET=uploads-development
|
44
|
+
```
|
45
|
+
|
46
|
+
Edit CORS config for the bucket
|
47
|
+
```
|
48
|
+
<CORSConfiguration>
|
49
|
+
<CORSRule>
|
50
|
+
<AllowedOrigin>http://localhost:5000</AllowedOrigin>
|
51
|
+
<AllowedMethod>GET</AllowedMethod>
|
52
|
+
<AllowedMethod>POST</AllowedMethod>
|
53
|
+
<AllowedMethod>PUT</AllowedMethod>
|
54
|
+
<AllowedHeader>*</AllowedHeader>
|
55
|
+
</CORSRule>
|
56
|
+
</CORSConfiguration>
|
44
57
|
```
|
45
58
|
|
46
59
|
## Usage
|
@@ -76,13 +89,32 @@ Post.update_picture_versions!
|
|
76
89
|
|
77
90
|
|
78
91
|
## Heroku
|
92
|
+
Create a production bucket on S3
|
93
|
+
Don't use your development bucket
|
94
|
+
```
|
95
|
+
<CORSConfiguration>
|
96
|
+
<CORSRule>
|
97
|
+
<AllowedOrigin>http://yourdomain.com</AllowedOrigin>
|
98
|
+
<AllowedMethod>GET</AllowedMethod>
|
99
|
+
<AllowedMethod>POST</AllowedMethod>
|
100
|
+
<AllowedMethod>PUT</AllowedMethod>
|
101
|
+
<AllowedHeader>*</AllowedHeader>
|
102
|
+
</CORSRule>
|
103
|
+
</CORSConfiguration>
|
104
|
+
```
|
105
|
+
|
79
106
|
Set environmet variables
|
80
107
|
```
|
81
|
-
|
82
|
-
|
108
|
+
heroku config:add
|
109
|
+
HEROKU_API_KEY=ab12acvc12 \
|
110
|
+
HEROKU_APP=your-app-name \
|
111
|
+
S3_KEY=AAAA123BBBB \
|
112
|
+
S3_SECRET=abc123ABcEffgee122 \
|
113
|
+
S3_REGION=us-east-1 \
|
114
|
+
S3_BUCKET=uploads-production \
|
83
115
|
```
|
84
116
|
|
85
|
-
Add Redis
|
117
|
+
Add Redis
|
86
118
|
```
|
87
119
|
heroku addons:add rediscloud:20
|
88
120
|
```
|
@@ -35,6 +35,8 @@ class @ImageUploader
|
|
35
35
|
@loader = $('<div class="progress progress-striped active"><div class="bar" style="width: 0%;"></div></div>').hide()
|
36
36
|
@preview.prepend(@loader.fadeIn())
|
37
37
|
data.submit()
|
38
|
+
@container.find('.fileupload').removeClass('processing').addClass('uploading')
|
39
|
+
@container.closest('form').find('[type=submit]').attr("disabled", true)
|
38
40
|
|
39
41
|
getFormData: (arg) =>
|
40
42
|
file = @file
|
@@ -54,6 +56,7 @@ class @ImageUploader
|
|
54
56
|
@loader.find('.bar').css({width: progress + '%'})
|
55
57
|
|
56
58
|
done: (e, data) =>
|
59
|
+
@container.find('.fileupload').removeClass('uploading').addClass('processing')
|
57
60
|
$.ajax
|
58
61
|
type: 'POST'
|
59
62
|
url: @fileInput.data('callback-url')
|
@@ -62,8 +65,14 @@ class @ImageUploader
|
|
62
65
|
'image[imageable_type]': @typeInput.val()
|
63
66
|
'image[upload_name]': @uploadNameInput.val()
|
64
67
|
'image[secure_random]': @fileInput.data('secure-random')
|
68
|
+
|
65
69
|
complete: =>
|
66
70
|
@verifyProcessingInterval = setInterval(@verifyProcessing, 5000)
|
71
|
+
|
72
|
+
error: =>
|
73
|
+
@loader.detach()
|
74
|
+
@container.find('.fileupload').removeClass('uploading').removeClass('processing')
|
75
|
+
@container.closest('form').find('[type=submit]').attr("disabled", false)
|
67
76
|
|
68
77
|
verifyProcessing: =>
|
69
78
|
arr = @filePath.split('/')
|
@@ -82,14 +91,22 @@ class @ImageUploader
|
|
82
91
|
if data.responseJSON.hasOwnProperty('id')
|
83
92
|
clearInterval(@verifyProcessingInterval)
|
84
93
|
@showThumb(data.responseJSON)
|
85
|
-
|
94
|
+
|
95
|
+
error: =>
|
96
|
+
@loader.detach()
|
97
|
+
@container.find('.fileupload').removeClass('uploading').removeClass('processing')
|
98
|
+
@container.closest('form').find('[type=submit]').attr("disabled", false)
|
99
|
+
|
100
|
+
|
86
101
|
delete: =>
|
87
102
|
@idInput.val('')
|
88
103
|
@container.find('.fileupload-preview.thumbnail img').detach()
|
89
104
|
@container.find('.fileupload').addClass('fileupload-new').removeClass('fileupload-exists')
|
90
105
|
|
91
106
|
fail: (e, data) =>
|
92
|
-
|
107
|
+
@loader.detach()
|
108
|
+
@container.find('.fileupload').removeClass('uploading').removeClass('processing')
|
109
|
+
@container.closest('form').find('[type=submit]').attr("disabled", false)
|
93
110
|
|
94
111
|
showThumb: (image) =>
|
95
112
|
@loader.detach()
|
@@ -102,7 +119,8 @@ class @ImageUploader
|
|
102
119
|
img.attr('height', @thumbContainer.data('height')).hide()
|
103
120
|
@container.find('.fileupload-preview.thumbnail').append(img.fadeIn())
|
104
121
|
@container.find('.fileupload').removeClass('fileupload-new').addClass('fileupload-exists')
|
105
|
-
|
122
|
+
@container.find('.fileupload').removeClass('uploading').removeClass('processing')
|
123
|
+
@container.closest('form').find('[type=submit]').attr("disabled", false)
|
106
124
|
|
107
125
|
$ ->
|
108
126
|
$('[data-component="ImageUploader"]').each (i, el) ->
|
@@ -3,7 +3,11 @@ module Uploadbox
|
|
3
3
|
layout false
|
4
4
|
|
5
5
|
def create
|
6
|
-
|
6
|
+
if Uploadbox.background_processing
|
7
|
+
Resque.enqueue(ProcessImage, image_params)
|
8
|
+
else
|
9
|
+
Image.create_upload(image_params)
|
10
|
+
end
|
7
11
|
render nothing: true
|
8
12
|
end
|
9
13
|
|
@@ -11,7 +15,7 @@ module Uploadbox
|
|
11
15
|
params[:imageable_type].constantize # load class
|
12
16
|
|
13
17
|
upload_class_name = params[:imageable_type] + params[:upload_name].camelize
|
14
|
-
@image = Uploadbox.const_get(upload_class_name).find_by(secure_random: params[:secure_random]
|
18
|
+
@image = Uploadbox.const_get(upload_class_name).find_by(secure_random: params[:secure_random])
|
15
19
|
end
|
16
20
|
|
17
21
|
def destroy
|
data/lib/uploadbox.rb
CHANGED
data/lib/uploadbox/version.rb
CHANGED