Skip to content

Instantly share code, notes, and snippets.

@yuyalush
Created September 13, 2013 02:33
Show Gist options
  • Save yuyalush/6546234 to your computer and use it in GitHub Desktop.
Save yuyalush/6546234 to your computer and use it in GitHub Desktop.
from RPi to CloudStrage
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