cloudphoto 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/.travis.yml +6 -0
- data/CHANGELOG.md +0 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +7 -0
- data/Gemfile.lock +52 -0
- data/LICENSE.txt +21 -0
- data/README.md +81 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/cloudphoto.gemspec +31 -0
- data/exe/cloudphoto +5 -0
- data/lib/cloudphoto.rb +6 -0
- data/lib/cloudphoto/aws/aws.rb +45 -0
- data/lib/cloudphoto/cli.rb +33 -0
- data/lib/cloudphoto/download.rb +13 -0
- data/lib/cloudphoto/help.rb +38 -0
- data/lib/cloudphoto/list.rb +38 -0
- data/lib/cloudphoto/upload.rb +19 -0
- data/lib/cloudphoto/version.rb +3 -0
- metadata +84 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: e9ef019fa79aa7bd1582bbde0be2e427fbf50211eb18862bf56a49665ce56be9
|
4
|
+
data.tar.gz: 8e013197356521a9674919a1ea1fe585ae43a43af41736e74c100d87057a04fd
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1b16cf4b7e25be346cf09176bcabaf045133fcbc86f1eede2eae7c0ab520d9fd751238f5040e11ba2753527a9ed15acfb1a0326fe1bcd3e03bb8a1a942942927
|
7
|
+
data.tar.gz: bcaac00b277b21376b2908d1ba6e0fabda9adeb06962d8c9d88f425597697eceab3fe235f18026cd6b7a93d4a6e36678cab66fbf4cc17e2aa23328608a8a524f
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CHANGELOG.md
ADDED
File without changes
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at dmitry.barskov@flatstack.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [https://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: https://contributor-covenant.org
|
74
|
+
[version]: https://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
cloudphoto (0.1.0)
|
5
|
+
aws-sdk-s3 (~> 1)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
aws-eventstream (1.1.0)
|
11
|
+
aws-partitions (1.399.0)
|
12
|
+
aws-sdk-core (3.109.3)
|
13
|
+
aws-eventstream (~> 1, >= 1.0.2)
|
14
|
+
aws-partitions (~> 1, >= 1.239.0)
|
15
|
+
aws-sigv4 (~> 1.1)
|
16
|
+
jmespath (~> 1.0)
|
17
|
+
aws-sdk-kms (1.39.0)
|
18
|
+
aws-sdk-core (~> 3, >= 3.109.0)
|
19
|
+
aws-sigv4 (~> 1.1)
|
20
|
+
aws-sdk-s3 (1.85.0)
|
21
|
+
aws-sdk-core (~> 3, >= 3.109.0)
|
22
|
+
aws-sdk-kms (~> 1)
|
23
|
+
aws-sigv4 (~> 1.1)
|
24
|
+
aws-sigv4 (1.2.2)
|
25
|
+
aws-eventstream (~> 1, >= 1.0.2)
|
26
|
+
diff-lcs (1.4.4)
|
27
|
+
jmespath (1.4.0)
|
28
|
+
rake (12.3.3)
|
29
|
+
rspec (3.10.0)
|
30
|
+
rspec-core (~> 3.10.0)
|
31
|
+
rspec-expectations (~> 3.10.0)
|
32
|
+
rspec-mocks (~> 3.10.0)
|
33
|
+
rspec-core (3.10.0)
|
34
|
+
rspec-support (~> 3.10.0)
|
35
|
+
rspec-expectations (3.10.0)
|
36
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
37
|
+
rspec-support (~> 3.10.0)
|
38
|
+
rspec-mocks (3.10.0)
|
39
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
40
|
+
rspec-support (~> 3.10.0)
|
41
|
+
rspec-support (3.10.0)
|
42
|
+
|
43
|
+
PLATFORMS
|
44
|
+
ruby
|
45
|
+
|
46
|
+
DEPENDENCIES
|
47
|
+
cloudphoto!
|
48
|
+
rake (~> 12.0)
|
49
|
+
rspec (~> 3.0)
|
50
|
+
|
51
|
+
BUNDLED WITH
|
52
|
+
2.1.4
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2020 Dmitry Barskov
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
# Cloudphoto
|
2
|
+
|
3
|
+
Command line utility for managing photos in AWS S3.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Install gem from command line:
|
8
|
+
|
9
|
+
```bash
|
10
|
+
gem install cloudphoto
|
11
|
+
```
|
12
|
+
|
13
|
+
## Usage
|
14
|
+
|
15
|
+
#### Configure environment vairables:
|
16
|
+
|
17
|
+
```bash
|
18
|
+
export AWS_REGION=us-east-1
|
19
|
+
```
|
20
|
+
see list of available regions [here](https://docs.aws.amazon.com/general/latest/gr/rande.html).
|
21
|
+
|
22
|
+
Configure AWS credentials in `~/.aws/credentials`
|
23
|
+
(see this [blog post](https://aws.amazon.com/blogs/security/a-new-and-standardized-way-to-manage-credentials-in-the-aws-sdks/)).
|
24
|
+
|
25
|
+
Provide bucket name
|
26
|
+
```bash
|
27
|
+
export CLOUDPHOTO_BUCKET=cloudphoto1
|
28
|
+
```
|
29
|
+
|
30
|
+
or pass it to executable
|
31
|
+
```bash
|
32
|
+
CLOUDPHOTO_BUCKET=photos cloudphoto list
|
33
|
+
```
|
34
|
+
|
35
|
+
### Upload pictures to cloud storage
|
36
|
+
|
37
|
+
Uploads all the photos (in jpeg/jpg format) from `path` directory (not recursively)
|
38
|
+
and adds them to `album` album.
|
39
|
+
|
40
|
+
```bash
|
41
|
+
cloudphoto upload -p path -a album
|
42
|
+
```
|
43
|
+
|
44
|
+
### Download pictures to have it locally
|
45
|
+
|
46
|
+
Downloads all the pictures related to `album` album to `path` directory.
|
47
|
+
|
48
|
+
```bash
|
49
|
+
cloudphoto download -p path -a album
|
50
|
+
```
|
51
|
+
|
52
|
+
### List albums in cloud storage
|
53
|
+
|
54
|
+
```bash
|
55
|
+
cloudphoto list
|
56
|
+
```
|
57
|
+
|
58
|
+
### List specific album photos in cloud storage
|
59
|
+
|
60
|
+
```bash
|
61
|
+
cloudphoto list -a album
|
62
|
+
```
|
63
|
+
|
64
|
+
## Development
|
65
|
+
|
66
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
67
|
+
|
68
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
69
|
+
|
70
|
+
## Contributing
|
71
|
+
|
72
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/DmitryBarskov/cloudphoto. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/DmitryBarskov/cloudphoto/blob/master/CODE_OF_CONDUCT.md).
|
73
|
+
|
74
|
+
|
75
|
+
## License
|
76
|
+
|
77
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
78
|
+
|
79
|
+
## Code of Conduct
|
80
|
+
|
81
|
+
Everyone interacting in the Cloudphoto project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/DmitryBarskov/cloudphoto/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "cloudphoto"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/cloudphoto.gemspec
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require_relative 'lib/cloudphoto/version'
|
2
|
+
|
3
|
+
Gem::Specification.new do |spec|
|
4
|
+
spec.name = "cloudphoto"
|
5
|
+
spec.version = Cloudphoto::VERSION
|
6
|
+
spec.authors = ["Dmitry Barskov"]
|
7
|
+
spec.email = ["dmitry.barskov64@gmail.com"]
|
8
|
+
|
9
|
+
spec.summary = "Simple photo gallery for AWS S3"
|
10
|
+
spec.description = "Upload photos, create albums on AWS S3 using CLI"
|
11
|
+
spec.homepage = "https://github.com/DmitryBarskov/cloudphoto"
|
12
|
+
spec.license = "MIT"
|
13
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
|
14
|
+
|
15
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
16
|
+
|
17
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
18
|
+
spec.metadata["source_code_uri"] = spec.homepage
|
19
|
+
spec.metadata["changelog_uri"] = "#{spec.homepage}/master/CHANGELOG.md"
|
20
|
+
|
21
|
+
# Specify which files should be added to the gem when it is released.
|
22
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
23
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
24
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
25
|
+
end
|
26
|
+
spec.bindir = "exe"
|
27
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
28
|
+
spec.require_paths = ["lib"]
|
29
|
+
|
30
|
+
spec.add_dependency "aws-sdk-s3", "~> 1"
|
31
|
+
end
|
data/exe/cloudphoto
ADDED
data/lib/cloudphoto.rb
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
require "aws-sdk-s3"
|
2
|
+
|
3
|
+
module Cloudphoto
|
4
|
+
module Aws
|
5
|
+
def s3_client
|
6
|
+
@s3_client ||= ::Aws::S3::Client.new(region: require_env("AWS_REGION"))
|
7
|
+
end
|
8
|
+
|
9
|
+
def s3_resource
|
10
|
+
@s3_resource ||= ::Aws::S3::Resource.new(client: s3_client)
|
11
|
+
end
|
12
|
+
|
13
|
+
def bucket
|
14
|
+
@bucket ||= require_env("CLOUDPHOTO_BUCKET")
|
15
|
+
end
|
16
|
+
|
17
|
+
def list_objects
|
18
|
+
s3_client.list_objects_v2(bucket: bucket).contents.map(&:key)
|
19
|
+
end
|
20
|
+
|
21
|
+
def upload_object(file_path, to:)
|
22
|
+
s3_client.put_object(bucket: bucket, key: to)
|
23
|
+
object = s3_resource.bucket(bucket).object(to)
|
24
|
+
File.open(file_path, 'rb') do |file|
|
25
|
+
object.put(body: file)
|
26
|
+
end
|
27
|
+
rescue StandardError => e
|
28
|
+
puts e
|
29
|
+
false
|
30
|
+
end
|
31
|
+
|
32
|
+
def download_object(key:, to:)
|
33
|
+
s3_client.get_object({ bucket: bucket, key: key }, target: to)
|
34
|
+
end
|
35
|
+
|
36
|
+
def require_env(key)
|
37
|
+
return ENV[key] if ENV[key]
|
38
|
+
|
39
|
+
raise ArgumentError.new("Missing environment variable #{key}")
|
40
|
+
end
|
41
|
+
|
42
|
+
module_function :require_env, :s3_client, :bucket, :list_objects,
|
43
|
+
:upload_object, :download_object, :s3_resource
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require "optparse"
|
2
|
+
|
3
|
+
require "cloudphoto/help"
|
4
|
+
require "cloudphoto/list"
|
5
|
+
require "cloudphoto/upload"
|
6
|
+
require "cloudphoto/download"
|
7
|
+
|
8
|
+
module Cloudphoto
|
9
|
+
def cli(command = "help", *args)
|
10
|
+
return Cloudphoto.help unless Cloudphoto.respond_to?(command)
|
11
|
+
|
12
|
+
options = {}
|
13
|
+
OptionParser.new do |opts|
|
14
|
+
opts.on("-a", "--album ALBUM", "Album name") do |album|
|
15
|
+
options[:album] = album
|
16
|
+
end
|
17
|
+
|
18
|
+
opts.on("-p", "--path path", "Path to upload/download photos to/from") do |path|
|
19
|
+
options[:path] = path
|
20
|
+
end
|
21
|
+
|
22
|
+
opts.on("-h", "--help", "Print this help") do
|
23
|
+
return Cloudphoto.help(command)
|
24
|
+
end
|
25
|
+
end.parse!(args)
|
26
|
+
|
27
|
+
Cloudphoto.send(command, **options) if options
|
28
|
+
rescue ArgumentError => e
|
29
|
+
puts e
|
30
|
+
Cloudphoto.help(command)
|
31
|
+
end
|
32
|
+
module_function :cli
|
33
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require "cloudphoto/aws/aws"
|
2
|
+
|
3
|
+
module Cloudphoto
|
4
|
+
def download(album:, path:)
|
5
|
+
photo_keys = Cloudphoto::List.list_keys("#{ALBUMS_PREFIX}/#{album}/")
|
6
|
+
|
7
|
+
photos = photo_keys.map do |key|
|
8
|
+
Cloudphoto::Aws.download_object(key: key, to: "#{path}/#{File.basename(key)}")
|
9
|
+
end
|
10
|
+
|
11
|
+
end
|
12
|
+
module_function :download
|
13
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module Cloudphoto
|
2
|
+
def help(command = nil)
|
3
|
+
puts <<~HELP
|
4
|
+
Usage: cloudphoto <command> [options]
|
5
|
+
Available commands:
|
6
|
+
download - download album from cloud storage
|
7
|
+
upload - upload photos to cloud storage
|
8
|
+
list - show ablum names in cloud storage
|
9
|
+
HELP
|
10
|
+
|
11
|
+
puts Help.send("help_#{command}") if command && respond_to?(command)
|
12
|
+
end
|
13
|
+
module_function :help
|
14
|
+
|
15
|
+
module Help
|
16
|
+
def help_upload
|
17
|
+
<<~HELP
|
18
|
+
cloudphoto upload -p path -a album
|
19
|
+
Upload all photos in **path** directory to **album** album
|
20
|
+
HELP
|
21
|
+
end
|
22
|
+
|
23
|
+
def help_download
|
24
|
+
<<~HELP
|
25
|
+
cloudphoto download -p path -a album
|
26
|
+
Download all photos from **album** album to **path** directory
|
27
|
+
HELP
|
28
|
+
end
|
29
|
+
|
30
|
+
def help_list
|
31
|
+
<<~HELP
|
32
|
+
cloudphoto list -a album
|
33
|
+
List available photos in **album** album
|
34
|
+
HELP
|
35
|
+
end
|
36
|
+
module_function :help_list, :help_download, :help_upload
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require "cloudphoto/aws/aws"
|
2
|
+
|
3
|
+
module Cloudphoto
|
4
|
+
def list(album: nil)
|
5
|
+
list = if album.nil?
|
6
|
+
List.list_albums
|
7
|
+
else
|
8
|
+
List.list_photos(album)
|
9
|
+
end
|
10
|
+
|
11
|
+
puts "total #{list.size}"
|
12
|
+
puts list
|
13
|
+
end
|
14
|
+
module_function :list
|
15
|
+
|
16
|
+
module List
|
17
|
+
def list_albums
|
18
|
+
albums = Cloudphoto::Aws.list_objects.select do |path|
|
19
|
+
/\A\.albums\/.+?\/\z/.match?(path)
|
20
|
+
end
|
21
|
+
albums.map! { |path| path.delete_prefix("#{ALBUMS_PREFIX}/").delete_suffix("/") }
|
22
|
+
end
|
23
|
+
|
24
|
+
def list_photos(album)
|
25
|
+
album_path = "#{ALBUMS_PREFIX}/#{album}/"
|
26
|
+
photos = list_keys(album_path)
|
27
|
+
photos.map! { |path| path.delete_prefix(album_path) }
|
28
|
+
end
|
29
|
+
|
30
|
+
def list_keys(prefix)
|
31
|
+
Cloudphoto::Aws.list_objects.select do |path|
|
32
|
+
path.start_with?(prefix)
|
33
|
+
end.reject { |path| path == prefix }
|
34
|
+
end
|
35
|
+
|
36
|
+
module_function :list_albums, :list_photos, :list_keys
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require "cloudphoto/aws/aws"
|
2
|
+
|
3
|
+
module Cloudphoto
|
4
|
+
def upload(path:, album:)
|
5
|
+
photos = Dir["#{path}/*.jpeg"] + Dir["#{path}/*.jpg"]
|
6
|
+
result = photos.map do |photo|
|
7
|
+
uploaded = Cloudphoto::Aws.upload_object(
|
8
|
+
photo,
|
9
|
+
to: "#{ALBUMS_PREFIX}/#{album}/#{File.basename(photo)}"
|
10
|
+
)
|
11
|
+
[photo, uploaded]
|
12
|
+
end
|
13
|
+
|
14
|
+
result.each do |path, success|
|
15
|
+
puts "Upload #{path} #{success ? 'done' : 'fail'}"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
module_function :upload
|
19
|
+
end
|
metadata
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cloudphoto
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Dmitry Barskov
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-11-28 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: aws-sdk-s3
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1'
|
27
|
+
description: Upload photos, create albums on AWS S3 using CLI
|
28
|
+
email:
|
29
|
+
- dmitry.barskov64@gmail.com
|
30
|
+
executables:
|
31
|
+
- cloudphoto
|
32
|
+
extensions: []
|
33
|
+
extra_rdoc_files: []
|
34
|
+
files:
|
35
|
+
- ".gitignore"
|
36
|
+
- ".rspec"
|
37
|
+
- ".travis.yml"
|
38
|
+
- CHANGELOG.md
|
39
|
+
- CODE_OF_CONDUCT.md
|
40
|
+
- Gemfile
|
41
|
+
- Gemfile.lock
|
42
|
+
- LICENSE.txt
|
43
|
+
- README.md
|
44
|
+
- Rakefile
|
45
|
+
- bin/console
|
46
|
+
- bin/setup
|
47
|
+
- cloudphoto.gemspec
|
48
|
+
- exe/cloudphoto
|
49
|
+
- lib/cloudphoto.rb
|
50
|
+
- lib/cloudphoto/aws/aws.rb
|
51
|
+
- lib/cloudphoto/cli.rb
|
52
|
+
- lib/cloudphoto/download.rb
|
53
|
+
- lib/cloudphoto/help.rb
|
54
|
+
- lib/cloudphoto/list.rb
|
55
|
+
- lib/cloudphoto/upload.rb
|
56
|
+
- lib/cloudphoto/version.rb
|
57
|
+
homepage: https://github.com/DmitryBarskov/cloudphoto
|
58
|
+
licenses:
|
59
|
+
- MIT
|
60
|
+
metadata:
|
61
|
+
allowed_push_host: https://rubygems.org
|
62
|
+
homepage_uri: https://github.com/DmitryBarskov/cloudphoto
|
63
|
+
source_code_uri: https://github.com/DmitryBarskov/cloudphoto
|
64
|
+
changelog_uri: https://github.com/DmitryBarskov/cloudphoto/master/CHANGELOG.md
|
65
|
+
post_install_message:
|
66
|
+
rdoc_options: []
|
67
|
+
require_paths:
|
68
|
+
- lib
|
69
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: 2.3.0
|
74
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
75
|
+
requirements:
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
79
|
+
requirements: []
|
80
|
+
rubygems_version: 3.1.2
|
81
|
+
signing_key:
|
82
|
+
specification_version: 4
|
83
|
+
summary: Simple photo gallery for AWS S3
|
84
|
+
test_files: []
|