Skip to content

Instantly share code, notes, and snippets.

@rjattrill
Last active December 16, 2020 19:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rjattrill/7415a9af49aeb7fa63c63c1caec8421c to your computer and use it in GitHub Desktop.
Save rjattrill/7415a9af49aeb7fa63c63c1caec8421c to your computer and use it in GitHub Desktop.
Receive YAML file in Sinatra
post '/import' do
contents = request.body.read
# Remove wrappers from the client FormData wrapper
yaml = contents.gsub(/^------WebKitFormBoundary.*\n|^Content-Disposition.*\n|^Content-Type.*\n/, '')
puts "YAML: #{yaml}"
end
# See also: https://gist.github.com/rjattrill/dd2d2597d4993433bcc6de7792a3a903 for a React/JavaScript sender.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment