Skip to content

Instantly share code, notes, and snippets.

@martinos
Created August 19, 2010 21:56
Show Gist options
  • Save martinos/539040 to your computer and use it in GitHub Desktop.
Save martinos/539040 to your computer and use it in GitHub Desktop.
module RemoteCopy
def rmcp(filename)
s3_connect
full_path = File.expand_path(filename)
basename = File.basename(full_path)
S3Object.store("file_name.txt", basename, 'RemoteClipboard')
S3Object.store("content", File.open(full_path), 'RemoteClipboard')
end
def rmpaste
s3_connect
file_name = S3Object.find("file_name.txt", 'RemoteClipboard').value
content = S3Object.find( 'content', 'RemoteClipboard').value
File.open(file_name, "w+") {|f| f << content}
end
private
def s3_connect
require 'aws/s3'
include AWS::S3
AWS::S3::Base.establish_connection!(
:access_key_id => ENV['AMAZON_ACCESS_KEY_ID'],
:secret_access_key => ENV['AMAZON_SECRET_ACCESS_KEY']
)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment