attached 0.3.9 → 0.4.0
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.
- data/lib/attached/attachment.rb +1 -7
- data/lib/attached/storage/aws.rb +26 -0
- data/lib/attached/storage/base.rb +11 -0
- data/lib/attached/storage/google.rb +26 -0
- data/lib/attached/storage/local.rb +13 -0
- data/lib/attached/storage/rackspace.rb +26 -0
- data/lib/attached/version.rb +1 -1
- metadata +3 -5
data/lib/attached/attachment.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'open-uri'
|
2
|
-
|
3
1
|
require 'guid'
|
4
2
|
|
5
3
|
require 'attached/storage'
|
@@ -316,11 +314,7 @@ module Attached
|
|
316
314
|
# Access the original file .
|
317
315
|
|
318
316
|
def reprocess!
|
319
|
-
|
320
|
-
root = "#{Rails.root}/public"
|
321
|
-
|
322
|
-
self.file ||= File.open("#{root}#{self.url}") unless uri.absolute?
|
323
|
-
self.file ||= open(uri)
|
317
|
+
self.file = self.storage.retrieve(self.path)
|
324
318
|
|
325
319
|
process
|
326
320
|
end
|
data/lib/attached/storage/aws.rb
CHANGED
@@ -69,6 +69,32 @@ module Attached
|
|
69
69
|
end
|
70
70
|
|
71
71
|
|
72
|
+
# Retrieve a file from a given path.
|
73
|
+
#
|
74
|
+
# Parameters:
|
75
|
+
#
|
76
|
+
# * path - The path to retrieve.
|
77
|
+
|
78
|
+
def retrieve(path)
|
79
|
+
directory = connection.directories.get(self.bucket)
|
80
|
+
directory ||= connection.directories.create(self.permissions.merge(:key => self.bucket))
|
81
|
+
|
82
|
+
file = directory.files.get(path)
|
83
|
+
|
84
|
+
body = file.body
|
85
|
+
|
86
|
+
extname = File.extname(path)
|
87
|
+
basename = File.basename(path, extname)
|
88
|
+
|
89
|
+
file = Tempfile.new([basename, extname])
|
90
|
+
file.binmode
|
91
|
+
file.write(body)
|
92
|
+
file.rewind
|
93
|
+
|
94
|
+
file
|
95
|
+
end
|
96
|
+
|
97
|
+
|
72
98
|
# Destroy a file at a given path.
|
73
99
|
#
|
74
100
|
# Parameters:
|
@@ -98,6 +98,17 @@ module Attached
|
|
98
98
|
end
|
99
99
|
|
100
100
|
|
101
|
+
# Retrieve a file from a given path.
|
102
|
+
#
|
103
|
+
# Parameters:
|
104
|
+
#
|
105
|
+
# * path - The path to retrieve.
|
106
|
+
|
107
|
+
def retrieve(path)
|
108
|
+
raise NotImplementedError.new
|
109
|
+
end
|
110
|
+
|
111
|
+
|
101
112
|
# Destroy a file at a given path (abstract).
|
102
113
|
#
|
103
114
|
# Parameters:
|
@@ -69,6 +69,32 @@ module Attached
|
|
69
69
|
end
|
70
70
|
|
71
71
|
|
72
|
+
# Retrieve a file from a given path.
|
73
|
+
#
|
74
|
+
# Parameters:
|
75
|
+
#
|
76
|
+
# * path - The path to retrieve.
|
77
|
+
|
78
|
+
def retrieve(path)
|
79
|
+
directory = connection.directories.get(self.bucket)
|
80
|
+
directory ||= connection.directories.create(self.permissions.merge(:key => self.bucket))
|
81
|
+
|
82
|
+
file = directory.files.get(path)
|
83
|
+
|
84
|
+
body = file.body
|
85
|
+
|
86
|
+
extname = File.extname(path)
|
87
|
+
basename = File.basename(path, extname)
|
88
|
+
|
89
|
+
file = Tempfile.new([basename, extname])
|
90
|
+
file.binmode
|
91
|
+
file.write(body)
|
92
|
+
file.rewind
|
93
|
+
|
94
|
+
file
|
95
|
+
end
|
96
|
+
|
97
|
+
|
72
98
|
# Destroy a file at a given path.
|
73
99
|
#
|
74
100
|
# Parameters:
|
@@ -52,6 +52,19 @@ module Attached
|
|
52
52
|
end
|
53
53
|
|
54
54
|
|
55
|
+
# Retrieve a file from a given path.
|
56
|
+
#
|
57
|
+
# Parameters:
|
58
|
+
#
|
59
|
+
# * path - The path to retrieve.
|
60
|
+
|
61
|
+
def retrieve(path)
|
62
|
+
path = "#{Rails.root}/public/system/#{path}"
|
63
|
+
|
64
|
+
File.open(path)
|
65
|
+
end
|
66
|
+
|
67
|
+
|
55
68
|
# Destroy a file at a given path.
|
56
69
|
#
|
57
70
|
# Parameters:
|
@@ -68,6 +68,32 @@ module Attached
|
|
68
68
|
end
|
69
69
|
|
70
70
|
|
71
|
+
# Retrieve a file from a given path.
|
72
|
+
#
|
73
|
+
# Parameters:
|
74
|
+
#
|
75
|
+
# * path - The path to retrieve.
|
76
|
+
|
77
|
+
def retrieve(path)
|
78
|
+
directory = connection.directories.get(self.bucket)
|
79
|
+
directory ||= connection.directories.create(self.permissions.merge(:key => self.bucket))
|
80
|
+
|
81
|
+
file = directory.files.get(path)
|
82
|
+
|
83
|
+
body = file.body
|
84
|
+
|
85
|
+
extname = File.extname(path)
|
86
|
+
basename = File.basename(path, extname)
|
87
|
+
|
88
|
+
file = Tempfile.new([basename, extname])
|
89
|
+
file.binmode
|
90
|
+
file.write(body)
|
91
|
+
file.rewind
|
92
|
+
|
93
|
+
file
|
94
|
+
end
|
95
|
+
|
96
|
+
|
71
97
|
# Destroy a file at a given path.
|
72
98
|
#
|
73
99
|
# Parameters:
|
data/lib/attached/version.rb
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: attached
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.
|
5
|
+
version: 0.4.0
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Kevin Sylvestre
|
@@ -10,8 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-06-
|
14
|
-
default_executable:
|
13
|
+
date: 2011-06-04 00:00:00 Z
|
15
14
|
dependencies:
|
16
15
|
- !ruby/object:Gem::Dependency
|
17
16
|
name: fog
|
@@ -66,7 +65,6 @@ files:
|
|
66
65
|
- LICENSE
|
67
66
|
- Gemfile
|
68
67
|
- Rakefile
|
69
|
-
has_rdoc: true
|
70
68
|
homepage: http://github.com/ksylvest/attached
|
71
69
|
licenses: []
|
72
70
|
|
@@ -90,7 +88,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
90
88
|
requirements: []
|
91
89
|
|
92
90
|
rubyforge_project:
|
93
|
-
rubygems_version: 1.
|
91
|
+
rubygems_version: 1.8.5
|
94
92
|
signing_key:
|
95
93
|
specification_version: 3
|
96
94
|
summary: An attachment library designed with cloud processors in mind
|