目录

FileChunkIO

FileChunkIO represents a chunk of an OS-level file containing bytes data. Python 2.6+ is required.

Background

I wrote FileChunkIO to upload huge files to Amazon S3 in multiple parts without having to split them physically upfront (which requires more time and twice the disk space) or creating in-memory chunks as StringIO instances.

Example

>>> from filechunkio import FileChunkIO
>>> chunk = FileChunkIO('LICENCE', offset=646, bytes=201)
>>> chunk.read()
'THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.'
>>> chunk.tell()
201L
>>> chunk.seek(4)
>>> chunk.read(8)
'SOFTWARE'
>>> chunk.seek(0)
>>> chunk.readline()
'THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n'
关于

用于处理大文件的分块读写操作

31.0 KB
邀请码
    Gitlink(确实开源)
  • 加入我们
  • 官网邮箱:gitlink@ccf.org.cn
  • QQ群
  • QQ群
  • 公众号
  • 公众号

版权所有:中国计算机学会技术支持:开源发展技术委员会
京ICP备13000930号-9 京公网安备 11010802047560号