anchor.diff:  %%%-------------------------------------------------------------------
  -%%% @author Lukasz Opiola
  -%%% @copyright (C) 2018 ACK CYFRONET AGH
  +%%% @author Bartosz Walkowicz
  +%%% @copyright (C) 2019 ACK CYFRONET AGH
   %%% This software is released under the MIT license 
   %%% cited in 'LICENSE.txt'.
   %%% @end
  
positive.code: %%% @end
  %%%-------------------------------------------------------------------
  -module(page_file_upload_new).
  -author("Lukasz Opiola").
  
  -behaviour(dynamic_page_behaviour).
  
  -include("global_definitions.hrl").
  -include("modules/fslogic/fslogic_common.hrl").
  -include_lib("ctool/include/http/codes.hrl").
  -include_lib("ctool/include/logging.hrl").
  -include_lib("ctool/include/api_errors.hrl").
  
  -define(CONN_CLOSE_HEADERS, #{<<"connection">> => <<"close">>}).
  
  %% Cowboy API
  -export([handle/2]).
  
  %% For test purpose
  -export([multipart/3]).
  
  
  %% ====================================================================
  
negative.code:             Host = cowboy_req:host(Req),
              SessionId = op_gui_session:initialize(Identity, Auth, Host),
              try
                  Req2 = handle_multipart_req(Req, SessionId, #{}),
                  cowboy_req:reply(?HTTP_200_OK, Req2)
              catch
                  throw:stream_file_error ->
                      cowboy_req:reply(
                          ?HTTP_500_INTERNAL_SERVER_ERROR,
                          ?CONN_CLOSE_HEADERS, Req
                      );
                  Type:Message ->
                      UserId = op_gui_session:get_user_id(),
                      ?error_stacktrace("Error while processing file upload "
                                        "from user ~p - ~p:~p", [
                          UserId, Type, Message
                      ]),
                      % @todo VFS-1815 for now return 500,
                      % because retries are not stable
  %%                    % Return 204 - resumable will retry the upload
  %%                    cowboy_req:reply(204, #{}, <<"">>)
                      cowboy_req:reply(
                          ?HTTP_500_INTERNAL_SERVER_ERROR,
                          ?CONN_CLOSE_HEADERS, Req
                      )
              end
      end.
  
  