paperclip-dropbox 1.1.2 → 1.1.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,50 +1,20 @@
1
1
  # Dropbox
2
2
 
3
3
  This gem extends [Paperclip](https://github.com/thoughtbot/paperclip) with
4
- Dropbox storage.
4
+ [Dropbox](https://www.dropbox.com) storage.
5
5
 
6
6
  ## Installation
7
7
 
8
- Put it in your `Gemfile`:
9
-
10
- ```ruby
11
- gem "paperclip-dropbox"
8
+ ```sh
9
+ $ gem install paperclip-dropbox
12
10
  ```
13
11
 
14
- And run `bundle install`.
15
-
16
12
  ## Dropbox Setup
17
13
 
18
14
  You must [create a Dropbox app](https://www.dropbox.com/developers/apps) and
19
15
  authorize it to access the Dropbox account you want to use for storage. You have
20
- a choice of two access types: **App folder** or **Full Dropbox**.
21
-
22
- ### "Full Dropbox" access
23
-
24
- Files will be stored in the [Public folder](https://www.dropbox.com/help/16/en).
25
- Download URLs are predictable, valid forever, and don't require an API call to
26
- retrieve, but this may not be a good thing if you don't want your files to be
27
- easily accessed. When using one account to store data for multiple sites (e.g.
28
- staging and production instances), it's up to you to make sure they don't step
29
- on each other's toes.
30
-
31
- Note that accounts created after October 4, 2012 don't have the Public folder
32
- enabled by default: [Go here](https://www.dropbox.com/enable_public_folder) to
33
- enable it. If you get a message that the folder is deleted, just create a folder
34
- in the root named "Public", and it should gain the special icon.
35
-
36
- ### "App folder" access
37
-
38
- Files will be stored in a subfolder under Apps (configurable in the app
39
- settings). Download URLs are generated on demand by calling the Dropbox API, and
40
- are only valid for 4 hours. This means your files are slightly "less public",
41
- and you can isolate data from multiple sites by creating multiple apps.
42
-
43
- **In app folder mode, every call to `#url` on an attachment will result in an
44
- HTTP request to Dropbox.** Whether or not this is acceptable will depend on what
45
- you're storing and how you're exposing it to users.
46
-
47
- ### Authorizing your app
16
+ a choice of two access types: **App folder** or **Full Dropbox**. You can read
17
+ about the differences in [this wiki](https://github.com/janko-m/paperclip-dropbox/wiki/Access-types).
48
18
 
49
19
  After creating your app, it will have an "App key" and "App secret". Provide
50
20
  these and the access type (`dropbox` or `app_folder`) to the authorization Rake task:
@@ -53,8 +23,8 @@ these and the access type (`dropbox` or `app_folder`) to the authorization Rake
53
23
  $ rake dropbox:authorize APP_KEY=your_app_key APP_SECRET=your_app_secret ACCESS_TYPE=your_access_type
54
24
  ```
55
25
 
56
- It will output an authorization URL that you must visit to grant the app access.
57
- It will then output your access token, access token secret, and user ID.
26
+ First it will give you an authorization URL that you must visit to grant the app access.
27
+ Then it will output your **access token**, and **user ID**.
58
28
 
59
29
  For non-Rails projects, you must require this task in your `Rakefile`:
60
30
 
@@ -84,23 +54,28 @@ authorization Rake task.
84
54
 
85
55
  Example `config/dropbox.yml`:
86
56
 
57
+ ```yaml
58
+ app_key: "APP_KEY"
59
+ app_secret: "APP_SECRET"
60
+ access_token: "ACCESS_TOKEN"
61
+ access_token_secret: "ACCESS_TOKEN_SECRET"
62
+ user_id: "USER_ID"
63
+ access_type: "ACCESS_TYPE"
64
+ ```
65
+
66
+ Of course, replace these strings with real values. The `"ACCESS_TYPE"`
67
+ must be either `"dropbox"` or `"app_folder"` depending on the access
68
+ type of your app; see **Dropbox Setup** above. If you're keeping your
69
+ credentials in environment variables (or something similar), you can also use
70
+ ERB:
71
+
87
72
  ```erb
88
73
  app_key: <%= ENV["DROPBOX_APP_KEY"] %>
89
- app_secret: <%= ENV["DROPBOX_APP_SECRET"] %>
90
- access_token: <%= ENV["DROPBOX_ACCESS_TOKEN"] %>
91
- access_token_secret: <%= ENV["DROPBOX_ACCESS_TOKEN_SECRET"] %>
92
- user_id: <%= ENV["DROPBOX_USER_ID"] %>
93
- access_type: <%= ENV["DROPBOX_ACCESS_TYPE"] %>
94
74
  ```
95
75
 
96
- It is good practice to not include the credentials directly in the YAML file.
97
- Instead you can set them in environment variables and embed them with ERB. Note
98
- `access_type` must be either `"dropbox"` or `"app_folder"` depending on the
99
- access type of your app; see **Dropbox Setup** above.
100
-
101
76
  You can also nest your credentials in environments (like in your `database.yml`):
102
77
 
103
- ```erb
78
+ ```yaml
104
79
  development:
105
80
  app_key: "..."
106
81
  ...
@@ -167,6 +142,15 @@ When using `app_folder` access type, `#url` always returns a direct link, and
167
142
  setting the `:download` option simply forces the file to be downloaded even if
168
143
  the browser would normally just display it.
169
144
 
145
+ ### Check if the file exists
146
+
147
+ You can easily check if the file exists on Dropbox:
148
+
149
+ ```ruby
150
+ user.avatar.exists?
151
+ # user.avatar.exists?(style)
152
+ ```
153
+
170
154
  ## License
171
155
 
172
- [MIT License](https://github.com/janko-m/paperclip-dropbox/blob/master/LICENSE)
156
+ [MIT License](LICENSE)
@@ -37,7 +37,7 @@ module Paperclip
37
37
  @queued_for_delete = []
38
38
  end
39
39
 
40
- def exists?(style)
40
+ def exists?(style = default_style)
41
41
  metadata = dropbox_metadata(style)
42
42
  !metadata.nil? && !metadata['is_deleted']
43
43
  rescue DropboxError
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |gem|
4
4
  gem.name = "paperclip-dropbox"
5
- gem.version = "1.1.2"
5
+ gem.version = "1.1.3"
6
6
  gem.platform = Gem::Platform::RUBY
7
7
 
8
8
  gem.homepage = "https://github.com/janko-m/paperclip-dropbox"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paperclip-dropbox
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.1.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-02-12 00:00:00.000000000 Z
12
+ date: 2013-04-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: paperclip
@@ -208,7 +208,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
208
208
  version: '0'
209
209
  segments:
210
210
  - 0
211
- hash: 569081523
211
+ hash: 503150639
212
212
  requirements: []
213
213
  rubyforge_project:
214
214
  rubygems_version: 1.8.23