Skip to content

Instantly share code, notes, and snippets.

@happyrobots
Created February 19, 2011 23:55
Show Gist options
  • Save happyrobots/835524 to your computer and use it in GitHub Desktop.
Save happyrobots/835524 to your computer and use it in GitHub Desktop.
quick and dirty file upload
def upload(to_be_uploaded, upload_directory)
uuid = UUIDTools::UUID.random_create
uniq_name = "#{uuid}#{to_be_uploaded.original_filename}"
uploaded_file = File.join(upload_directory, uniq_name)
File.open(uploaded_file, "w") { |f| f.write(to_be_uploaded.read) }
uploaded_file
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment