                         else
                             uid = id
                             c()
+                (c) ->
+                    ensure_containing_directory_exists(mesg.project_id, uid, path, c)
+                (c) ->
+                    fs.writeFile(path, value.blob, c)
                 # Set the permissions on the file to the correct user (instead of root)
                 (c) ->
                     fs.chown(path, uid, uid, c)

            socket.write_mesg 'json', message.error(id:mesg.id, error:err)
    )

# Write a file to the project
events.write_file_to_project = (socket, mesg) ->
    data_uuid = mesg.data_uuid

                        if err
                            c(err)
                        else
                            path = realpath
                            c()
                (c) ->
                    getuid user, (err, id) ->
                        if err
