Skip to content

Instantly share code, notes, and snippets.

@blinsay

blinsay/thing.rb Secret

Created October 17, 2014 21:42
Show Gist options
  • Save blinsay/0395f57d274e71057d01 to your computer and use it in GitHub Desktop.
Save blinsay/0395f57d274e71057d01 to your computer and use it in GitHub Desktop.
def put(thing io, overwrite = false)
# NOTE: This is an extra call to S3.
if exists?(thing) && !overwrite
raise "Thing already exists in S3. Refusing to overwrite"
end
metadata = ObjectMetadata.new
metadata.content_length = io.size
@client.putObject(bucket, build_key(thing), io.to_inputstream, metadata)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment