3 class UploadsController < ApiController
4 before_action :check_api_writable
5 before_action :authorize
7 authorize_resource :class => Changeset
9 before_action :require_public_data
11 skip_around_action :api_call_timeout
13 # Helper methods for checking consistency
14 include ConsistencyValidations
17 # Upload a diff in a single transaction.
19 # This means that each change within the diff must succeed, i.e: that
20 # each version number mentioned is still current. Otherwise the entire
21 # transaction *must* be rolled back.
23 # Furthermore, each element in the diff can only reference the current
26 # Returns: a diffResult document, as described in
27 # http://wiki.openstreetmap.org/wiki/OSM_Protocol_Version_0.6
29 changeset = Changeset.find(params[:changeset_id])
30 check_changeset_consistency(changeset, current_user)
32 diff_reader = DiffReader.new(request.raw_post, changeset)
33 Changeset.transaction do
34 result = diff_reader.commit
35 # the number of changes in this changeset has already been
36 # updated and is visible in this transaction so we don't need
37 # to allow for any more when checking the limit
39 render :xml => result.to_s