paperclipdropbox 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +40 -0
- data/lib/paperclipdropbox/version.rb +1 -1
- data/lib/paperclipdropbox.rb +9 -4
- data/paperclipdropbox.gemspec +1 -1
- metadata +45 -36
data/README.rdoc
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
= PaperclipDropboxStorage
|
2
|
+
|
3
|
+
Dropbox storage support for paperclip file attachment plugin.
|
4
|
+
|
5
|
+
== Install
|
6
|
+
|
7
|
+
gem install paperclipdropbox
|
8
|
+
|
9
|
+
|
10
|
+
== Usage
|
11
|
+
|
12
|
+
Create the file config/paperclipdropbox.yml:
|
13
|
+
|
14
|
+
development:
|
15
|
+
dropbox_user: user_email
|
16
|
+
dropbox_password: user_password
|
17
|
+
dropbox_key: developer_app_key
|
18
|
+
dropbox_secret: developer_app_secret
|
19
|
+
|
20
|
+
test:
|
21
|
+
...
|
22
|
+
|
23
|
+
production:
|
24
|
+
...
|
25
|
+
|
26
|
+
In your model:
|
27
|
+
|
28
|
+
class User < ActiveRecord::Base
|
29
|
+
has_attached_file :avatar,
|
30
|
+
:styles => { :medium => "300x300>", :thumb => "100x100>" },
|
31
|
+
:storage => :Dropboxstorage,
|
32
|
+
:path => "/:attachment/:attachment/:id/:style/:filename"
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
You can add the path option to the config/paperclipdropbox.yml file for ease of use.
|
37
|
+
|
38
|
+
|
39
|
+
Till I have a production dropbox key/secret you will need to create your own via dropbox.
|
40
|
+
The developer key will only allow access to the developers dropbox and nothing else.
|
data/lib/paperclipdropbox.rb
CHANGED
@@ -4,7 +4,11 @@ module Paperclip
|
|
4
4
|
def self.extended(base)
|
5
5
|
require "dropbox"
|
6
6
|
base.instance_eval do
|
7
|
-
|
7
|
+
|
8
|
+
if File.exists?("#{RAILS_ROOT}/config/paperclipdropbox.yml")
|
9
|
+
@options.merge!(YAML.load_file("#{RAILS_ROOT}/config/paperclipdropbox.yml")[Rails.env].symbolize_keys)
|
10
|
+
end
|
11
|
+
|
8
12
|
@dropbox_user = @options[:dropbox_user]
|
9
13
|
@dropbox_password = @options[:dropbox_password]
|
10
14
|
@dropbox_key = @options[:dropbox_key]
|
@@ -20,7 +24,7 @@ module Paperclip
|
|
20
24
|
def exists?(style = default_style)
|
21
25
|
log("exists? #{style}")
|
22
26
|
begin
|
23
|
-
dropbox_session.metadata(style)
|
27
|
+
dropbox_session.metadata("/Public#{File.dirname(path(style))}")
|
24
28
|
log("true")
|
25
29
|
true
|
26
30
|
rescue
|
@@ -35,8 +39,9 @@ module Paperclip
|
|
35
39
|
end
|
36
40
|
|
37
41
|
def flush_writes #:nodoc:
|
42
|
+
log("[paperclip] Writing files #{@queued_for_write.count}")
|
38
43
|
@queued_for_write.each do |style, file|
|
39
|
-
log("[paperclip] Writing files for
|
44
|
+
log("[paperclip] Writing files for ")
|
40
45
|
file.close
|
41
46
|
dropbox_session.upload(file.path, "/Public#{File.dirname(path(style))}", :as=> File.basename(path(style)))
|
42
47
|
end
|
@@ -45,7 +50,7 @@ module Paperclip
|
|
45
50
|
|
46
51
|
def flush_deletes #:nodoc:
|
47
52
|
@queued_for_delete.each do |path|
|
48
|
-
log("[paperclip] Deleting files for #{path
|
53
|
+
log("[paperclip] Deleting files for #{path}")
|
49
54
|
dropbox_session.rm("/Public/#{path}")
|
50
55
|
end
|
51
56
|
@queued_for_delete = []
|
data/paperclipdropbox.gemspec
CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |s|
|
|
8
8
|
s.platform = Gem::Platform::RUBY
|
9
9
|
s.authors = ["Paul Ketelle"]
|
10
10
|
s.email = ["paul@ketelle.com"]
|
11
|
-
s.homepage = ""
|
11
|
+
s.homepage = "https://github.com/dripster82/paperclipdropbox"
|
12
12
|
s.summary = %q{Dropbox storage support for paperclip file attachment}
|
13
13
|
s.description = %q{Dropbox storage support for paperclip file attachment}
|
14
14
|
|
metadata
CHANGED
@@ -1,73 +1,82 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: paperclipdropbox
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.1
|
3
|
+
version: !ruby/object:Gem::Version
|
5
4
|
prerelease:
|
5
|
+
version: 0.0.2
|
6
6
|
platform: ruby
|
7
|
-
authors:
|
7
|
+
authors:
|
8
8
|
- Paul Ketelle
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
|
13
|
+
date: 2011-05-03 00:00:00 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
15
16
|
name: paperclip
|
16
|
-
|
17
|
+
prerelease: false
|
18
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
17
19
|
none: false
|
18
|
-
requirements:
|
19
|
-
- -
|
20
|
-
- !ruby/object:Gem::Version
|
21
|
-
version:
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "0"
|
22
24
|
type: :runtime
|
23
|
-
|
24
|
-
|
25
|
-
- !ruby/object:Gem::Dependency
|
25
|
+
version_requirements: *id001
|
26
|
+
- !ruby/object:Gem::Dependency
|
26
27
|
name: dropbox
|
27
|
-
|
28
|
+
prerelease: false
|
29
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
28
30
|
none: false
|
29
|
-
requirements:
|
30
|
-
- -
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
version:
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: "0"
|
33
35
|
type: :runtime
|
34
|
-
|
35
|
-
version_requirements: *11286612
|
36
|
+
version_requirements: *id002
|
36
37
|
description: Dropbox storage support for paperclip file attachment
|
37
|
-
email:
|
38
|
+
email:
|
38
39
|
- paul@ketelle.com
|
39
40
|
executables: []
|
41
|
+
|
40
42
|
extensions: []
|
43
|
+
|
41
44
|
extra_rdoc_files: []
|
42
|
-
|
45
|
+
|
46
|
+
files:
|
43
47
|
- .gitignore
|
44
48
|
- Gemfile
|
49
|
+
- README.rdoc
|
45
50
|
- Rakefile
|
46
51
|
- lib/paperclipdropbox.rb
|
47
52
|
- lib/paperclipdropbox/version.rb
|
48
53
|
- paperclipdropbox.gemspec
|
49
|
-
homepage:
|
54
|
+
homepage: https://github.com/dripster82/paperclipdropbox
|
50
55
|
licenses: []
|
56
|
+
|
51
57
|
post_install_message:
|
52
58
|
rdoc_options: []
|
53
|
-
|
59
|
+
|
60
|
+
require_paths:
|
54
61
|
- lib
|
55
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
62
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
56
63
|
none: false
|
57
|
-
requirements:
|
58
|
-
- -
|
59
|
-
- !ruby/object:Gem::Version
|
60
|
-
version:
|
61
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: "0"
|
68
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
62
69
|
none: false
|
63
|
-
requirements:
|
64
|
-
- -
|
65
|
-
- !ruby/object:Gem::Version
|
66
|
-
version:
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: "0"
|
67
74
|
requirements: []
|
75
|
+
|
68
76
|
rubyforge_project: paperclipdropbox
|
69
77
|
rubygems_version: 1.7.2
|
70
78
|
signing_key:
|
71
79
|
specification_version: 3
|
72
80
|
summary: Dropbox storage support for paperclip file attachment
|
73
81
|
test_files: []
|
82
|
+
|