#!/bin/sh

set -e

sanitized=$(echo $PATH_INFO | tr -s ' ' '_')

# move one dir up and look if file exists there
if [ -f ..$sanitized ]; then
        # changed this line
        dd of=/dev/null # post request has to be processed in some way!
        echo "Status: 409 Conflict"
        echo 'Content-Type: text/plain'
        echo ''
        echo "File already exists."
        exit 0
fi`enter code here`

# creating file
mkdir -p ..$(dirname $sanitized)
# changed following line
# directing binary data stream from post request to that file
dd of=..$sanitized 

# File upload successful message
echo 'Status: 204 No Content'
echo "X-File-Name: $(basename $sanitized)"
echo "X-File-Path: $(dirname $sanitized)"
echo ''
