且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

.NET core/Python 从 Azure Storage Blob 读取前 X 行

更新时间:2023-01-07 11:32:24

我有一个大的 blob,我需要从中提取前几行.我可以在不打开整个文件的情况下执行此操作吗?

I have a large blob which I need to extract the first few rows from. Can I do this without opening the entire file?

答案是肯定的和否定的.是的,你可以阅读部分内容,但是你不能阅读前几行.

The answer is both yes and no. Yes, you can read partial contents however you can't read the first few lines.

本质上,Blob 存储服务允许您执行范围读取,您可以在其中指定要读取的数据范围(起始字节和要读取的字节数).在请求中指定范围后,Azure 存储将仅返回这些字节.

Essentially Blob Storage Service allows you to perform a range read where you can specify the range of data (starting bytes and number of bytes to read) that you want to read. Once the range is specified in the request, Azure Storage will only return those bytes.

如果您使用的是 .Net SDK,请查看 DownloadStreaming 方法.

If you're using .Net SDK, please look at DownloadStreaming method.