anchor.diff:              {ok, UploadRef} = couch:attach("user_uploads", FileKey, {Filename, stream}, Opts),
   
               %% commit upload
  -            {ok, {ResultList}, Req3, _} = stream_file(Req2, UploadRef, CryptoState),
  +            {ok, {ResultList}, Req3, _} = stream_receive_file(Req2, UploadRef, CryptoState),
   
               Rev1 = proplists:get_value(<<"rev">>, ResultList),
               Id = proplists:get_value(<<"id">>, ResultList),
  
positive.code: 
                    case Attachment of
                      false -> echo(200, jiffy:encode({FileKVList}), Req);
                      _ -> %% TODO Support stremming mode
                        CType = proplists:get_value(<<"ctype">>, FileKVList),
                        FileName = proplists:get_value(<<"filename">>, FileKVList),
  
                        case couch:fetch_attachment("user_uploads", FileKey, FileName) of
                          {ok, EncrResult} ->
  
                            State = crypto:stream_init(aes_ctr, AESKey, AESIV),
                            {_, Result} = crypto:stream_decrypt(State, EncrResult),
  
                            cowboy_req:reply(200, [
                              {<<"content-type">>, CType},
                              {<<"server">>, <<"myinbox-datastore">>}
                            ], Result, Req);
  
                          _ -> end_with_failure(404, "Not Found", Req)
                        end
  
negative.code:       {ok, Req2, FieldList, FileList}
    end.
  
  stream_receive_file(Req, UploadRef, CryptoState) ->
    case cowboy_req:part_body(Req) of
      {ok, Body, Req2} ->
        {NewCryptoState, CipherBody} = crypto:stream_encrypt(CryptoState, Body),
  