anchor.diff:              ])},
   
               {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),
   
  
positive.code:             Doc = {lists:concat([
                DocKVList,
                [
                  %% {<<"_id">>, Id},
                  %% {<<"_rev">>, Rev1},
                  {<<"ukey">>, UKey},
                  {<<"fileKey">>, list_to_binary(FileKey)},
                  {<<"fieldName">>, FieldName},
                  {<<"filename">>, Filename},
                  {<<"ctype">>, CType},
  
negative.code:             {ok, UploadRef} = couch:attach("user_uploads", FileKey, {Filename, stream}, Opts),
  
              %% commit upload
              {ok, {ResultList}, Req3, _} = stream_file(Req2, UploadRef, CryptoState),
  
              Rev1 = proplists:get_value(<<"rev">>, ResultList),
              Id = proplists:get_value(<<"id">>, ResultList),
  