Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

Not able to upload file using webhdfs

Not able to upload file using webhdfs

New Contributor

Below is what i did.

 

$ kinit -kt abc.keytab abc@XXX.COM
$ curl --negotiate -u : -i -X PUT "http://xxx.com:14000/webhdfs/v1/tmp/sample.txt?op=CREATE"
HTTP/1.1 401 Unauthorized
Server: Apache-Coyote/1.1
WWW-Authenticate: Negotiate
Set-Cookie: hadoop.auth=; Path=/; Expires=Thu, 01-Jan-1970 00:00:00 GMT; HttpOnly
Content-Type: text/html;charset=utf-8
Content-Length: 997
Date: Sat, 03 Sep 2016 10:43:56 GMT

HTTP/1.1 307 Temporary Redirect
Server: Apache-Coyote/1.1
Set-Cookie: hadoop.auth="u=abc&p=abc@XXX.COM&t=kerberos-dt&e=147293905&s=TE3dsc5Zi9qpH5GNok="; Path=/; Expires=Sat, 03-Sep-2016 20:43:56 GMT; HttpOnly
Location: http://xyz.com:14000/webhdfs/v1/tmp/sample.txt?op=CREATE&data=true
Content-Type: application/json
Content-Length: 0
Date: Sat, 03 Sep 2016 10:43:56 GMT

$ curl --negotiate -i -u : -X PUT -T "/tmp/sample.txt" "http://xyz.com:14000/webhdfs/v1/tmp/sample.txt?op=CREATE&data=true"
HTTP/1.1 100 Continue

HTTP/1.1 401 Unauthorized
Server: Apache-Coyote/1.1
WWW-Authenticate: Negotiate
Set-Cookie: hadoop.auth=; Path=/; Expires=Thu, 01-Jan-1970 00:00:00 GMT; HttpOnly
Content-Type: text/html;charset=utf-8
Content-Length: 997
Date: Sat, 03 Sep 2016 10:44:17 GMT

HTTP/1.1 400 Bad Request
Server: Apache-Coyote/1.1
Transfer-Encoding: chunked
Date: Sat, 03 Sep 2016 10:44:17 GMT
Connection: close

 

Please help.

2 REPLIES 2

Re: Not able to upload file using webhdfs

Master Guru
Please try adding a header to the second request, denoting a binary request type as opposed to leaving it at the default "text/html" that curl issues if unspecified:

curl --negotiate -i -u : -H "Content-Type: application/octet-stream" -X PUT -T "/tmp/sample.txt" "http://xyz.com:14000/webhdfs/v1/tmp/sample.txt?op=CREATE&data=true"

Re: Not able to upload file using webhdfs

New Contributor

Thanks Harsh, but i tried that already without sucess. I tried with both type of content "application/octet-stream" also with "text/xml".

 

$ curl --negotiate -i -u : -H "Content-Type: application/octet-stream" -X PUT -T "/tmp/sample.txt" "http://xyz.com:14000/webhdfs/v1/tmp/sample.txt?op=CREATE&data=true"
HTTP/1.1 100 Continue

HTTP/1.1 401 Unauthorized
Server: Apache-Coyote/1.1
WWW-Authenticate: Negotiate
Set-Cookie: hadoop.auth=; Path=/; Expires=Thu, 01-Jan-1970 00:00:00 GMT; HttpOnly
Content-Type: text/html;charset=utf-8
Content-Length: 997
Date: Sat, 03 Sep 2016 12:36:20 GMT

HTTP/1.1 400 Bad Request
Server: Apache-Coyote/1.1
Transfer-Encoding: chunked
Date: Sat, 03 Sep 2016 12:36:20 GMT
Connection: close

 

The thing i am suspecting is the absence of any error messege. Any guide to move forward will be of great help.

Don't have an account?
Coming from Hortonworks? Activate your account here