Created
September 13, 2013 02:33
-
-
Save yuyalush/6546234 to your computer and use it in GitHub Desktop.
from RPi to CloudStrage
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "aws" | |
bucket_name = "pic" | |
file_name = "pic-#{Time.now.strftime("%Y%m%d%H%M%S")}.jpg" | |
dir_name = '/home/pi/picup/pics/' | |
system('/opt/vc/bin/raspistill -w 480 -h 360 -o ' + dir_name + file_name) | |
ncs = AWS::S3.new( | |
access_key_id: "-----", | |
secret_access_key: "-----", | |
s3_endpoint: "west-1-ncss.nifty.com" | |
) | |
b = ncs.buckets[bucket_name] | |
Dir::chdir(dir_name) | |
Dir.glob("**/*").each do |f| | |
next if FileTest::directory?(f) | |
o = b.objects[f] | |
o.write(:file => f, :acl => :public_read) | |
puts o.public_url | |
File.delete(f) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment