-Re: RES: I want to call HDFS REST api to upload a file using httplib.
Try adding -L to your curl and see if that works.
On Apr 8, 2013, at 11:05 PM, 小学园PHP wrote:
But the returned URL is wrong. And the localhost is the real URL, as i tested successfully with curl using "localhost".
Can anybody help me translate the curl to Python httplib?
curl -i -X PUT -T <LOCAL_FILE> "http://<DATANODE>:<PORT>/webhdfs/v1/<PATH>?op=CREATE"
I test it using python httplib, and receive the right response. But the file uploaded to HDFS is empty, no data sent!!
Is "conn.send(data)" the problem?
------------------ Original ------------------
From: "MARCOS MEDRADO RUBINELLI"<[EMAIL PROTECTED]<mailto:[EMAIL PROTECTED]>>;
Date: Mon, Apr 8, 2013 04:22 PM
To: "[EMAIL PROTECTED]<mailto:[EMAIL PROTECTED]>"<[EMAIL PROTECTED]<mailto:[EMAIL PROTECTED]>>;
Subject: RES: I want to call HDFS REST api to upload a file using httplib.
On your first call, Hadoop will return a URL pointing to a datanode in the Location header of the 307 response. On your second call, you have to use that URL instead of constructing your own. You can see the specific documentation here:
I want to call HDFS REST api to upload a file using httplib.
My program created the file, but no content is in it.
Here is my code:
Here is the return:
307 TEMPORARY_REDIRECT 201 Created
OK, the file was created, but no content was sent.
When I comment the #conn.send(data), the result is the same, still no content.
Maybe the file read or the send is wrong, not sure.
Do you know how this happened?