Transfer byte stream to HDFS using JAVA

Is it possible to upload a file using some web-service directly to HDFS space. I tried to write file in to local system and moved it to HDFS.

Upvotes: 0

Views: 112

Answers (1)

Rima
Rima

Reputation: 545

WebHDFS provides REST APIs to support all the filesystem operations.

Direct uploading is not possible though.

It has to follow 2 steps

  1. Create File in the hdfs location http://<HOST>:<PORT>/webhdfs/v1/<PATH>?op=CREATE
  2. Write to that file - by specifying your local file path tat u want to upload in the Header http://<DATANODE>:<PORT>/webhdfs/v1/<PATH>?op=CREATE

Refer APIs here WebHDFS apis

Upvotes: 4

Related Questions