skyer9 commented on a change in pull request #4271:
URL: https://github.com/apache/zeppelin/pull/4271#discussion_r763685131



##########
File path: 
zeppelin-server/src/main/java/org/apache/zeppelin/rest/NotebookRestApi.java
##########
@@ -614,6 +619,51 @@ public Response updateParagraphConfig(@PathParam("noteId") 
String noteId,
     return new JsonResponse<>(Status.OK, "", p).build();
   }
 
+  /**
+   * Download paragraph
+   * @param noteId
+   * @param paragraphId
+   * @return data stream
+   * @throws IOException
+   */
+  @GET
+  @Produces("text/csv")
+  @Path("{notebookId}/paragraph/{paragraphId}/download")
+  @ZeppelinApi
+  public Response downParagraph(@PathParam("notebookId") String noteId,
+                                @PathParam("paragraphId") String paragraphId)
+          throws IOException {
+    LOGGER.info("Download paragraph, node.id: {}, paragrap.id: {}", noteId, 
paragraphId);
+
+    Note note = notebook.getNote(noteId);
+    if (note == null) {
+      return new JsonResponse(Status.NOT_FOUND, "note not found.").build();
+    }
+
+    Paragraph p = note.getParagraph(paragraphId);
+    if (p == null) {
+      return new JsonResponse(Status.NOT_FOUND, "paragraph not 
found.").build();
+    }
+
+    String resultFileParent = 
conf.getString(ZeppelinConfiguration.ConfVars.ZEPPELIN_RESULT_DATA_DIR);
+
+    String fileName = noteId + "_" + paragraphId;
+    final File file = new File(resultFileParent + "/" + fileName);

Review comment:
       thank you for review my code.
   changed to OS path separator.
   and replaced "/tmp" to System.getProperty("java.io.tmpdir")




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@zeppelin.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to