通过Data Lake Gen2 REST API创建文件会生成一个空白文件。 [英] Creating a file via the Data Lake Gen2 REST API results in a blank file.

查看:117
本文介绍了通过Data Lake Gen2 REST API创建文件会生成一个空白文件。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 $ b上传文件$ b Gen2 REST API路径 - 创建端点。

我发送PUT请求到  https://myaccount.dfs.core.windows.net/myfilesystem/json-file.json?resource=file

I send a PUT request to https://myaccount.dfs.core.windows.net/myfilesystem/json-file.json?resource=file

使用以下标题:

x-ms-version:2018-11-09
$
内容长度:0

内容类型:application / json

x-ms-version:2018-11-09
Content-Length:0
Content-Type:application/json

这个简单的JSON字符串作为正文

And this simple JSON string as the body

{

" name":" John"

}

{
"name": "John"
}

API响应201 Created和我确实在Storage Explorer中看到了该文件。但是当我下载它时,它是0字节,空的。

The API responds with 201 Created and I do see the file in the Storage Explorer. But when I download it, it's 0 bytes, empty.

我缺少什么?




推荐答案

请使用这两个调用来写入一个文件,即用作创建文件资源的文件。

Please use these two call to write to a file , the one which you used as creates a file resource .

以下命令将文本添加到file1的开头。

The following command adds text to the beginning of file1.

printf '数据行1 \数据行2 \ n'| curl -i -X PATCH -H" x-ms-version:2018-11-09" -H"授权:承载

printf 'data row 1\ndata row 2\n' | curl -i -X PATCH -H "x-ms-version: 2018-11-09" -H "Authorization: Bearer


ACCESS_TOKEN" --data-binary @ - " https://
ACCESS_TOKEN" --data-binary @- "https://


STORAGE_ACCOUNT_NAME.dfs.core.windows.net/mydata/data/file1?action=append&position=0"
STORAGE_ACCOUNT_NAME.dfs.core.windows.net/mydata/data/file1?action=append&position=0"

完成后,服务器返回202 Accepted响应。

Once complete, the server returns a 202 Accepted response.

现有数据已存在于file1中,以下命令将数据附加到现有数据价值。

With existing data already in file1, the following command appends data to the existing value.

printf'数据行3 \数据行4 \ n'| curl -i -X PATCH -H" x-ms-version:2018-11-09" -H"授权:持票人

printf 'data row 3\ndata row 4\n' | curl -i -X PATCH -H "x-ms-version: 2018-11-09" -H "Authorization: Bearer


这篇关于通过Data Lake Gen2 REST API创建文件会生成一个空白文件。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆