Last active
December 16, 2020 19:04
-
-
Save rjattrill/7415a9af49aeb7fa63c63c1caec8421c to your computer and use it in GitHub Desktop.
Receive YAML file in Sinatra
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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