anchor.diff:              {ok, UploadRef} = couch:attach("user_uploads", FileKey, {Filename, stream}, Opts),
   
               %% commit upload
  -            {ok, {ResultList}, Req3} = stream_file(Req2, UploadRef),
  +            {ok, {ResultList}, Req3, _} = stream_file(Req2, UploadRef, CryptoState),
   
               Rev1 = proplists:get_value(<<"rev">>, ResultList),
               Id = proplists:get_value(<<"id">>, ResultList),
  
positive.code:             {ok, Req3, FieldList1, FileList};
            {file, FieldName, Filename, CType, CTransferEncoding} ->
  
              FileKey = lists:concat([
                binary_to_list(UKey),
                "_",
                hash_md5:build(binary_to_list(Filename))
              ]),
  
              Opts =
                case couch:get("user_uploads", FileKey) of
  
negative.code:             ])},
  
              {ok, ResultDoc} = couch:save("user_uploads", Doc),
  
              case couch:get("user_uploads_essentials", FileKey) of
                {ok, {EssKVList}} ->
                  Ref = proplists:get_value(<<"_id">>, EssKVList),
                  Rev2 = proplists:get_value(<<"_rev">>, EssKVList),
                  couch:save("user_uploads_essentials",
                    {[{<<"aes_key">>, base64:encode(AESKey)},
                      {<<"aes_iv">>, base64:encode(AESIV)},
                      {<<"fileKey">>, FileKeyBin}]},
                    [{<<"_id">>, Ref}, {<<"_rev">>, Rev2}]);
                _ ->
                  couch:save("user_uploads_essentials",
                    {[{<<"_id">>, FileKeyBin},
                      {<<"aes_key">>, base64:encode(AESKey)},
                      {<<"aes_iv">>, base64:encode(AESIV)},
                      {<<"fileKey">>, FileKeyBin}]})
              end,
  
              FileList1 = lists:append([{Filename, ResultDoc}], FileList),
  
  