anchor.diff:  }).
   
   %% Callbacks
  --export([init/3, rest_init/2, resource_exists/2, allowed_methods/2, content_types_provided/2,content_types_accepted/2, delete_resource/2]).
  +-export([init/3, rest_init/2, resource_exists/2, allowed_methods/2, content_types_provided/2, content_types_accepted/2, delete_resource/2]).
   -export([put_dir/2, put_cdmi_file/2, put_noncdmi_file/2, get_dir/2, get_cdmi_file/2, get_noncdmi_file/2]).
   
   %% init/3
  
positive.code: %% @end
  -spec put_cdmi_file(req(), #state{}) -> {term(), req(), #state{}}.
  %% ====================================================================
  put_cdmi_file(Req,#state{filepath = Filepath} = State) ->
      {ok,RawBody,_} = cowboy_req:body(Req),
      Body = parse_body(RawBody),
      ValueTransferEncoding = proplists:get_value(<<"valuetransferencoding">>,Body,<<"utf-8">>),  %todo check given body opts, store given mimetype
      Value = proplists:get_value(<<"value">>,Body,<<>>),
      RawValue = case ValueTransferEncoding of
          <<"base64">> -> base64:decode(Value);
          <<"utf-8">> -> Value
      end,
      case logical_files_manager:create(Filepath) of
          ok ->
              case logical_files_manager:write(Filepath,RawValue) of
                  Bytes when is_integer(Bytes) andalso Bytes == byte_size(RawValue) ->
                      Response = rest_utils:encode_to_json({struct, prepare_object_ans(?default_post_file_opts,State)}),
                      Req2 = cowboy_req:set_resp_body(Response, Req),
                      {true,Req2,State};
                  Error ->
                      ?error("Writing to cdmi object end up with error: ~p", [Error]),
                      logical_files_manager:delete(Filepath),
                      {ok,Req2} = cowboy_req:reply(?error_forbidden_code,Req),
                      {halt, Req2, State}
              end;
          {error, file_exists} ->
              {ok,Req2} = cowboy_req:reply(?error_conflict_code,Req),
              {halt, Req2, State};
          Error -> %todo handle common errors
              ?error("Creating cdmi object end up with error: ~p", [Error]),
              {ok,Req2} = cowboy_req:reply(?error_forbidden_code,Req),
              {halt, Req2, State}
      end.
  
  
negative.code: %% @end
  -spec put_noncdmi_file(req(), #state{}) -> {term(), req(), #state{}}.
  %% ====================================================================
  put_noncdmi_file(Req, #state{filepath = Filepath} = State) ->
      case logical_files_manager:create(Filepath) of %todo can be potentially refactored and combined with put_cdmi_file (some code is duplicated)
          ok ->
              write_body_to_file(Req, State, 0);
          {error, file_exists} ->
              {ok, Req2} = cowboy_req:reply(?error_conflict_code, Req),
              {halt, Req2, State};
          Error ->
              ?error("Creating cdmi object end up with error: ~p", [Error]),
              {ok, Req2} = cowboy_req:reply(?error_forbidden_code, Req),
              {halt, Req2, State}
      end.
  
  