I am communicating with HDFS using curl. Procedure to interact with HDFS via webhdfs is two steps and I receive a url from a first curl command:
create_request=$(curl -i -X PUT "http:/somewhere:50070/webhdfs/v1/${path}?op=CREATE")
destination=$(echo "$create_request" | grep Location | cut -d " " -f 2)
Using the destination
variable, I can upload my file with the following:
curl -i -X PUT -T $local_file_path "$destination"
However, the above commands throws :
curl: (3) URL using bad/illegal format or missing URL
Using the exact same command but changing $destination
bby the URL it contains (writting it manually) works file.
Why do I have this problem and how to solve this ?
PS: $destination
does contain the data: http://datanode:50075/webhdfs/v1/path/test/file.jar?op=CREATE&namenoderpcaddress=cluster&overwrite=false
Edit: Quoting
path="mypath"
local_file_path="untitled.txt"
create_request="$(curl -i -X PUT "http://ip:50070/webhdfs/v1/${path}?op=CREATE")"
destination="$(echo "$create_request" | grep "Location"| cut -d ' ' -f 2)"
curl -i -X PUT -T "$local_file_path" "$destination"
Gives the same error message.