You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@zeppelin.apache.org by GitBox <gi...@apache.org> on 2021/12/06 15:29:23 UTC

[GitHub] [zeppelin] Reamer commented on a change in pull request #4271: [ZEPPELIN-3493] "Export all data as csv" not exporting all data

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



##########
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:
       Please use the following constructor, which takes the OS path separator into account. https://docs.oracle.com/javase/7/docs/api/java/io/File.html#File(java.lang.String,%20java.lang.String)




-- 
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-unsubscribe@zeppelin.apache.org

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