upcloudify 0.0.3 → 0.1.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.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/README.md +1 -1
- data/lib/upcloudify/version.rb +1 -1
- data/lib/upcloudify.rb +25 -12
- data/sample_app/Gemfile +5 -0
- data/sample_app/sample.rb +23 -0
- data/sample_app/views/index.erb +8 -0
- data/upcloudify.gemspec +2 -0
- metadata +34 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3b384a4aa972b795a902500e84510f881ef51961
|
4
|
+
data.tar.gz: f9d69b5caee4682cd0a86a48ab16fd47ebd3fbba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a8e47a6899af9b30fa3dfbf9e76ea80a3df22429c23047f6027448a6fb00f29989b1474ab74826aee2948db796f08c96281b562a31371d8aa533583d206a555d
|
7
|
+
data.tar.gz: 177e5cd7d57d5cd03c2719a1a0305fc652af08f6bc6f2bf065e6584c7c08dba0cf94e6ad5295ab8659c9091cceb443556c212b5f3fd1cf7fa9d0b1b75f39088f
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -25,7 +25,7 @@ Configure the app:
|
|
25
25
|
Upcloudify.configure do |config|
|
26
26
|
config.aws_secret_access_key = 'foobarbaz' # can also be ENV['AWS_SECRET_ACCESS_KEY']
|
27
27
|
config.aws_access_key_id = 'hello' # can also be ENV['AWS_ACCESS_KEY_ID']
|
28
|
-
config.aws_directory = '
|
28
|
+
config.aws_directory = 'aws-directory'
|
29
29
|
end
|
30
30
|
```
|
31
31
|
|
data/lib/upcloudify/version.rb
CHANGED
data/lib/upcloudify.rb
CHANGED
@@ -17,15 +17,25 @@ module Upcloudify
|
|
17
17
|
|
18
18
|
class S3
|
19
19
|
|
20
|
-
|
20
|
+
def initialize(options = {
|
21
|
+
s3_id: Upcloudify.configuration.aws_access_key_id,
|
22
|
+
s3_secret: Upcloudify.configuration.aws_secret_access_key,
|
23
|
+
s3_directory: Upcloudify.configuration.aws_directory
|
24
|
+
})
|
25
|
+
@id = options[:s3_id]
|
26
|
+
@secret = options[:s3_secret]
|
27
|
+
@directory = options[:s3_directory]
|
28
|
+
end
|
29
|
+
|
30
|
+
# Internal: Connects to Amazon S3 using stored credentials
|
21
31
|
# Returns an object handle for the S3 bucket-directory
|
22
32
|
def cloud
|
23
33
|
connection = Fog::Storage.new(
|
24
34
|
:provider => 'AWS',
|
25
|
-
:aws_secret_access_key =>
|
26
|
-
:aws_access_key_id =>
|
35
|
+
:aws_secret_access_key => @secret,
|
36
|
+
:aws_access_key_id => @id,
|
27
37
|
)
|
28
|
-
directory = connection.directories.get(
|
38
|
+
directory = connection.directories.get(@directory)
|
29
39
|
directory.files
|
30
40
|
end
|
31
41
|
|
@@ -34,7 +44,7 @@ module Upcloudify
|
|
34
44
|
def upload(filename, data)
|
35
45
|
file = cloud.create(
|
36
46
|
key: "#{filename}.zip",
|
37
|
-
body: Zippy.new("#{filename}
|
47
|
+
body: Zippy.new("#{filename}" => data).data,
|
38
48
|
:public => false
|
39
49
|
)
|
40
50
|
file
|
@@ -42,23 +52,26 @@ module Upcloudify
|
|
42
52
|
|
43
53
|
# Public: Uploads a file to S3 and emails a link to the file.
|
44
54
|
# Returns nothing.
|
45
|
-
def email(
|
55
|
+
def email(email_address,
|
46
56
|
filename,
|
47
57
|
attachment,
|
48
|
-
options=
|
49
|
-
|
58
|
+
options = {
|
59
|
+
suffix: " generated on #{Time.now.to_s}-#{Rails.env}",
|
60
|
+
expiration: Time.now.tomorrow,
|
50
61
|
from: 'upcloudify',
|
51
62
|
subject: 'your file is attached',
|
52
|
-
body: 'your report is linked '
|
53
|
-
|
63
|
+
body: 'your report is linked '
|
64
|
+
}
|
65
|
+
)
|
66
|
+
|
54
67
|
suffix = options[:suffix]
|
55
68
|
expiration = options[:expiration]
|
56
69
|
file = upload((filename.to_s + suffix.to_s).parameterize, attachment)
|
57
70
|
|
58
|
-
Pony.mail to:
|
71
|
+
Pony.mail to: email_address,
|
59
72
|
from: options[:from],
|
60
73
|
subject: options[:subject],
|
61
|
-
body: (options[:body] || '') + file.url(expiration)
|
74
|
+
body: (options[:body] || '') + file.url(expiration) + ' '
|
62
75
|
|
63
76
|
end
|
64
77
|
|
data/sample_app/Gemfile
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'sinatra'
|
2
|
+
require 'pry'
|
3
|
+
require 'upcloudify'
|
4
|
+
require 'active_support/all'
|
5
|
+
|
6
|
+
enable :sessions
|
7
|
+
|
8
|
+
get '/' do
|
9
|
+
erb :index
|
10
|
+
end
|
11
|
+
|
12
|
+
post '/upload' do
|
13
|
+
Upcloudify.configure do |config|
|
14
|
+
config.aws_access_key_id = params["s3_id"]
|
15
|
+
config.aws_secret_access_key = params["s3_key"]
|
16
|
+
config.aws_directory = params["s3_directory"]
|
17
|
+
end
|
18
|
+
|
19
|
+
uploader = Upcloudify::S3.new
|
20
|
+
|
21
|
+
uploader.email(params["email"], params["file"]["filename"], params["file"]["tempfile"])
|
22
|
+
# redirect '/'
|
23
|
+
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
<form method="post" action="/upload" enctype='multipart/form-data'>
|
2
|
+
S3 Secret ID <input name="s3_id" type="text" /><br />
|
3
|
+
S3 Secret Key <input name="s3_key" type="text" /><br />
|
4
|
+
S3 Directory <input name="s3_directory" type="text" /><br />
|
5
|
+
Email <input name="email" type="text" /><br />
|
6
|
+
File <input name="file" type="file"><br />
|
7
|
+
<input type="submit" />
|
8
|
+
</form>
|
data/upcloudify.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: upcloudify
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- parasquid
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-12-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - '>='
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: zip-zip
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
98
|
name: fog
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -94,6 +108,20 @@ dependencies:
|
|
94
108
|
- - '>='
|
95
109
|
- !ruby/object:Gem::Version
|
96
110
|
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: activesupport
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - '>='
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
97
125
|
description: |-
|
98
126
|
Upcloudify simplifies the process for uploading
|
99
127
|
attachments to the cloud and emailing the recipient
|
@@ -111,6 +139,9 @@ files:
|
|
111
139
|
- Rakefile
|
112
140
|
- lib/upcloudify.rb
|
113
141
|
- lib/upcloudify/version.rb
|
142
|
+
- sample_app/Gemfile
|
143
|
+
- sample_app/sample.rb
|
144
|
+
- sample_app/views/index.erb
|
114
145
|
- upcloudify.gemspec
|
115
146
|
homepage: ''
|
116
147
|
licenses:
|
@@ -132,7 +163,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
132
163
|
version: '0'
|
133
164
|
requirements: []
|
134
165
|
rubyforge_project:
|
135
|
-
rubygems_version: 2.
|
166
|
+
rubygems_version: 2.2.2
|
136
167
|
signing_key:
|
137
168
|
specification_version: 4
|
138
169
|
summary: Upload a file to the cloud and email a link for the attachment
|