Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/hadoop/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Hadoop 通过HDFSAPI将文件上载到hdfs会导致文件被追加并带有签名_Hadoop_Hdfs - Fatal编程技术网

Hadoop 通过HDFSAPI将文件上载到hdfs会导致文件被追加并带有签名

Hadoop 通过HDFSAPI将文件上载到hdfs会导致文件被追加并带有签名,hadoop,hdfs,Hadoop,Hdfs,我的目标是上传一个文件,我的代码是这样的: headers = { 'Some_Auth_Stuff': _get_ca_cert(ROLE), 'Host': host, } files = {'upload_file': file} params = ( ('op', 'create'), ('permission', '755') ) r = requests.put( 'https://proxystuff.hostname.com/fs%s

我的目标是上传一个文件,我的代码是这样的:

headers = {
    'Some_Auth_Stuff': _get_ca_cert(ROLE),
    'Host': host,
}

files = {'upload_file': file}

params = (
    ('op', 'create'),
    ('permission', '755')
)

r = requests.put(
    'https://proxystuff.hostname.com/fs%s' % hue_path,
    headers=headers, files=files, params=params)

if r.status_code == 201:
    return True
return False
我正在上传这个文件:

i am a test file
我得到了201响应,这很好,但当我查看文件时,它看起来是这样的:

--04dc34a8a49d4b83878473d6d78e683d
Content-Disposition: form-data; name="upload_file"; filename="testfile"

i am a test file

--04dc34a8a49d4b83878473d6d78e683d--
当涉及到上传内容时,我是否遗漏了什么?有没有什么方法可以禁止该文件获取前置和追加的内容

编辑: 如果我使用这个curl命令,效果很好

curl -c cookie -b cookie -T "test.txt" "https://proxystuff.hostname.com/fs/user/stupidfatcat/test.txt?op=create&permission=755" -H "Some_Auth_Stuff:blahblah" -H "Host:someotherhost_with_hadoop.com:4443"

在尝试了一些东西之后,如果我把它改成

headers=headers, data=file.read(), params=params
我将内容类型设置为plain/text,效果很好,似乎不喜欢file param