attache 2.1.0 → 2.1.1
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 +36 -21
- data/lib/attache/download.rb +1 -1
- data/lib/attache/version.rb +1 -1
- data/lib/attache/vhost.rb +8 -3
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1438a328d3cedfa04d52dcbe33d1b168be8ccd98
|
4
|
+
data.tar.gz: 0676c54d6050a8280247fa4e48ade32ec749edaf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 25f7bdb0321d6850f7e42002fa54670654260f670023d3a119b587302f704efc303f2ef2c6ba8bcb852d77b7f35a66f11332b6fd2dc260940f94090ed25f523b
|
7
|
+
data.tar.gz: bea5d1625b2235168897f5978de5fb1dbb62a5a9ec65af10a1264e7204c5397939b0d5447129ca2fff3b72e79c09956f90298f533c6815788f108cf97a007a32
|
data/README.md
CHANGED
@@ -1,8 +1,18 @@
|
|
1
1
|
# attache
|
2
2
|
|
3
|
+
[](https://badge.fury.io/rb/attache)
|
3
4
|
[](https://travis-ci.org/choonkeat/attache)
|
4
5
|
|
5
|
-
##
|
6
|
+
## But why?
|
7
|
+
|
8
|
+
If you're interested in the "why", checkout [my slides](http://www.slideshare.net/choonkeat/file-upload-2015) and [the blog post](http://blog.choonkeat.com/weblog/2015/10/file-uploads-2015.html).
|
9
|
+
|
10
|
+
Your app can easily support
|
11
|
+
- dynamic resize of images (no predefined styles in your app)
|
12
|
+
- all file types since attache let apps [display non-image files as icons through `<img src...>`](https://github.com/choonkeat/attache/pull/28)
|
13
|
+
- resumeable upload over unreliable (mobile) networks [using TUS protocol](https://github.com/choonkeat/attache/pull/10)
|
14
|
+
|
15
|
+
## Run an instance
|
6
16
|
|
7
17
|
#### Heroku
|
8
18
|
|
@@ -18,19 +28,6 @@ docker run -it -p 9292:5000 --rm attache/attache
|
|
18
28
|
|
19
29
|
Also, see [Deploying Attache on Digital Ocean using Docker](https://github.com/choonkeat/attache/wiki/Deploying-Attache-on-Digital-Ocean-using-Docker)
|
20
30
|
|
21
|
-
#### Source code
|
22
|
-
|
23
|
-
You can checkout the source code and run it like a regular [a Procfile-based app](ddollar.github.io/foreman/)
|
24
|
-
|
25
|
-
```
|
26
|
-
git clone https://github.com/choonkeat/attache.git
|
27
|
-
cd attache
|
28
|
-
bundle install
|
29
|
-
foreman start -c web=1 -p 9292
|
30
|
-
```
|
31
|
-
|
32
|
-
See [foreman](https://github.com/ddollar/foreman) for more details.
|
33
|
-
|
34
31
|
#### RubyGem
|
35
32
|
|
36
33
|
You can install the gem and then execute `attache` command
|
@@ -68,7 +65,20 @@ bundle exec attache start -c web=1 -p 9292
|
|
68
65
|
|
69
66
|
NOTE: some config files will be written into your current directory (see RubyGems above)
|
70
67
|
|
71
|
-
|
68
|
+
#### Source code
|
69
|
+
|
70
|
+
You can checkout the source code and run it like a regular [a Procfile-based app](ddollar.github.io/foreman/)
|
71
|
+
|
72
|
+
```
|
73
|
+
git clone https://github.com/choonkeat/attache.git
|
74
|
+
cd attache
|
75
|
+
bundle install
|
76
|
+
foreman start -c web=1 -p 9292
|
77
|
+
```
|
78
|
+
|
79
|
+
See [foreman](https://github.com/ddollar/foreman) for more details.
|
80
|
+
|
81
|
+
## Configuration
|
72
82
|
|
73
83
|
`LOCAL_DIR` is where your local disk cache will be. By default, attache will use a system assigned temporary directory which may not be the same everytime you run attache.
|
74
84
|
|
@@ -82,7 +92,7 @@ However if you prefer a more durable queue for reliable uploads, configuring `RE
|
|
82
92
|
|
83
93
|
If for some reason you'd want the cloud storage delete to be synchronous, set `INLINE_JOB=1` instead.
|
84
94
|
|
85
|
-
#### Cloud Storage
|
95
|
+
#### Virtual Host Cloud Storage
|
86
96
|
|
87
97
|
`attache` uses a different config (and backup files into a different cloud service) depending on the request hostname that it was accessed by.
|
88
98
|
|
@@ -102,9 +112,15 @@ heroku config:set VHOST=$(bundle exec rake attache:vhost)
|
|
102
112
|
|
103
113
|
#### Virtual Host Authorization
|
104
114
|
|
105
|
-
By default `attache` will accept uploads and delete requests from any client.
|
115
|
+
By default `attache` will accept uploads and delete requests from any client. Set `SECRET_KEY` to ensure attache only receives upload (and delete commands) from your own app.
|
116
|
+
|
117
|
+
To most app developers *using* attache in your rails app through a library like [attache-rails gem](https://github.com/choonkeat/attache-rails), how this work may not matter. But if you are developing attache itself or writing a client library for attache, then read on.
|
118
|
+
|
119
|
+
#### Virtual Host Authorization (Developer)
|
106
120
|
|
107
|
-
When `SECRET_KEY` is set, `attache` will require a valid `hmac` parameter in the upload request. Upload and Delete requests will be refused with `HTTP 401` error unless the `hmac` is correct.
|
121
|
+
When `SECRET_KEY` is set, `attache` will require a valid `hmac` parameter in the upload request. Upload and Delete requests will be refused with `HTTP 401` error unless the `hmac` is correct.
|
122
|
+
|
123
|
+
The additional parameters required for authorized request are:
|
108
124
|
|
109
125
|
* `uuid` is a uuid string
|
110
126
|
* `expiration` is a unix timestamp of a future time. the significance is, if the timestamp has passed, the upload will be regarded as invalid
|
@@ -116,8 +132,6 @@ i.e.
|
|
116
132
|
hmac = OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha1'), SECRET_KEY, uuid + expiration)
|
117
133
|
```
|
118
134
|
|
119
|
-
This will be transparent to you when using integration libraries like [attache_rails gem](https://github.com/choonkeat/attache_rails).
|
120
|
-
|
121
135
|
## APIs
|
122
136
|
|
123
137
|
The attache server is a reference implementation of these interfaces. If you write your own server, [compatibility can be verified by running a test suite](https://github.com/choonkeat/attache_api#testing-against-an-attache-compatible-server).
|
@@ -126,7 +140,6 @@ The attache server is a reference implementation of these interfaces. If you wri
|
|
126
140
|
|
127
141
|
Users will upload files directly into the `attache` server from their browser, bypassing the main app.
|
128
142
|
|
129
|
-
|
130
143
|
> ```
|
131
144
|
> PUT /upload?file=image123.jpg
|
132
145
|
> ```
|
@@ -181,6 +194,8 @@ The `paths` value should be delimited by the newline character, aka `\n`. In the
|
|
181
194
|
> paths=image1.jpg%0Aprefix2%2Fimage2.jpg%0Aimage3.jpg
|
182
195
|
> ```
|
183
196
|
|
197
|
+
This feature might be known as `promote` in other file upload solutions. `attache` allows client app to `backup` uploaded images to another bucket for longer term storage.
|
198
|
+
|
184
199
|
Copying 1 or more files from the default remote storage to the backup remote storage (backup) can be done via a http `POST` request to `/backup`, with a `paths` parameter in the request body.
|
185
200
|
|
186
201
|
The `paths` value should be delimited by the newline character, aka `\n`. In the example above, 3 files will be requested for backup: `image1.jpg`, `prefix2/image2.jpg`, and `image3.jpg`.
|
data/lib/attache/download.rb
CHANGED
data/lib/attache/version.rb
CHANGED
data/lib/attache/vhost.rb
CHANGED
@@ -44,11 +44,16 @@ class Attache::VHost
|
|
44
44
|
end
|
45
45
|
|
46
46
|
def storage_url(args)
|
47
|
-
remote_api.new({
|
47
|
+
object = remote_api.new({
|
48
48
|
key: File.join(*remotedir, args[:relpath]),
|
49
|
-
})
|
50
|
-
|
49
|
+
})
|
50
|
+
result = if object.respond_to?(:url)
|
51
|
+
object.url(Time.now + 600)
|
52
|
+
else
|
53
|
+
object.public_url
|
51
54
|
end
|
55
|
+
ensure
|
56
|
+
Attache.logger.info "storage_url: #{result}"
|
52
57
|
end
|
53
58
|
|
54
59
|
def storage_get(args)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: attache
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- choonkeat
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-02-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: activesupport
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: paperclip
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|