@@ -585,23 +585,21 @@ public Response post(InputStream is,
585585 switch (op .value ()) {
586586 case APPEND : {
587587 Boolean hasData = params .get (DataParam .NAME , DataParam .class );
588- if (!hasData ) {
589- URI redirectURL = createUploadRedirectionURL (
590- uriInfo , HttpFSFileSystem .Operation .APPEND );
591- Boolean noRedirect = params .get (
592- NoRedirectParam .NAME , NoRedirectParam .class );
593- if (noRedirect ) {
588+ URI redirectURL = createUploadRedirectionURL (uriInfo ,
589+ HttpFSFileSystem .Operation .APPEND );
590+ Boolean noRedirect =
591+ params .get (NoRedirectParam .NAME , NoRedirectParam .class );
592+ if (noRedirect ) {
594593 final String js = JsonUtil .toJsonString ("Location" , redirectURL );
595594 response = Response .ok (js ).type (MediaType .APPLICATION_JSON ).build ();
596- } else {
597- response = Response .temporaryRedirect (redirectURL ).build ();
598- }
599- } else {
595+ } else if (hasData ) {
600596 FSOperations .FSAppend command =
601597 new FSOperations .FSAppend (is , path );
602598 fsExecute (user , command );
603599 AUDIT_LOG .info ("[{}]" , path );
604600 response = Response .ok ().type (MediaType .APPLICATION_JSON ).build ();
601+ } else {
602+ response = Response .temporaryRedirect (redirectURL ).build ();
605603 }
606604 break ;
607605 }
@@ -662,7 +660,8 @@ public Response post(InputStream is,
662660 protected URI createUploadRedirectionURL (UriInfo uriInfo , Enum <?> uploadOperation ) {
663661 UriBuilder uriBuilder = uriInfo .getRequestUriBuilder ();
664662 uriBuilder = uriBuilder .replaceQueryParam (OperationParam .NAME , uploadOperation ).
665- queryParam (DataParam .NAME , Boolean .TRUE );
663+ queryParam (DataParam .NAME , Boolean .TRUE )
664+ .replaceQueryParam (NoRedirectParam .NAME , (Object []) null );
666665 return uriBuilder .build (null );
667666 }
668667
@@ -726,18 +725,14 @@ public Response put(InputStream is,
726725 switch (op .value ()) {
727726 case CREATE : {
728727 Boolean hasData = params .get (DataParam .NAME , DataParam .class );
729- if (!hasData ) {
730- URI redirectURL = createUploadRedirectionURL (
731- uriInfo , HttpFSFileSystem .Operation .CREATE );
732- Boolean noRedirect = params .get (
733- NoRedirectParam .NAME , NoRedirectParam .class );
734- if (noRedirect ) {
728+ URI redirectURL = createUploadRedirectionURL (uriInfo ,
729+ HttpFSFileSystem .Operation .CREATE );
730+ Boolean noRedirect =
731+ params .get (NoRedirectParam .NAME , NoRedirectParam .class );
732+ if (noRedirect ) {
735733 final String js = JsonUtil .toJsonString ("Location" , redirectURL );
736734 response = Response .ok (js ).type (MediaType .APPLICATION_JSON ).build ();
737- } else {
738- response = Response .temporaryRedirect (redirectURL ).build ();
739- }
740- } else {
735+ } else if (hasData ) {
741736 Short permission = params .get (PermissionParam .NAME ,
742737 PermissionParam .class );
743738 Short unmaskedPermission = params .get (UnmaskedPermissionParam .NAME ,
@@ -761,6 +756,8 @@ public Response put(InputStream is,
761756 "Location" , uriInfo .getAbsolutePath ());
762757 response = Response .created (uriInfo .getAbsolutePath ())
763758 .type (MediaType .APPLICATION_JSON ).entity (js ).build ();
759+ } else {
760+ response = Response .temporaryRedirect (redirectURL ).build ();
764761 }
765762 break ;
766763 }
0 commit comments