Skip to content

Impossible to get only the first byte of a file using get_blob_to_bytes with start_range and end_range #410

@robhobbes

Description

@robhobbes

I was writing unit tests for something that uses azure-storage-python and noticed that you cannot get just the first byte.

Python 3.6.1 (default, Oct  2 2017, 20:46:59) 
[GCC 6.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from azure.storage.blob import BlockBlobService
>>> blob_service = BlockBlobService(REDACTED, REDACTED)
>>> deck = blob_service.get_blob_to_bytes('test', 'deck.txt').content
>>> blob_service.get_blob_to_bytes('test', 'deck.txt').content
b'\xf0\x9f\x82\xa1\xf0\x9f\x82\xa2\xf0\x9f\x82\xa3\xf0\x9f\x82\xa4\xf0\x9f\x82\xa5\xf0\x9f\x82\xa6\xf0\x9f\x82\xa7\xf0\x9f\x82\xa8\xf0\x9f\x82\xa9\xf0\x9f\x82\xaa\xf0\x9f\x82\xab\xf0\x9f\x82\xac\xf0\x9f\x82\xad\xf0\x9f\x82\xae\n\xf0\x9f\x82\xb1\xf0\x9f\x82\xb2\xf0\x9f\x82\xb3\xf0\x9f\x82\xb4\xf0\x9f\x82\xb5\xf0\x9f\x82\xb6\xf0\x9f\x82\xb7\xf0\x9f\x82\xb8\xf0\x9f\x82\xb9\xf0\x9f\x82\xba\xf0\x9f\x82\xbb\xf0\x9f\x82\xbc\xf0\x9f\x82\xbd\xf0\x9f\x82\xbe\n\xf0\x9f\x83\x81\xf0\x9f\x83\x82\xf0\x9f\x83\x83\xf0\x9f\x83\x84\xf0\x9f\x83\x85\xf0\x9f\x83\x86\xf0\x9f\x83\x87\xf0\x9f\x83\x88\xf0\x9f\x83\x89\xf0\x9f\x83\x8a\xf0\x9f\x83\x8b\xf0\x9f\x83\x8c\xf0\x9f\x83\x8d\xf0\x9f\x83\x8e\n\xf0\x9f\x83\x91\xf0\x9f\x83\x92\xf0\x9f\x83\x93\xf0\x9f\x83\x94\xf0\x9f\x83\x95\xf0\x9f\x83\x96\xf0\x9f\x83\x97\xf0\x9f\x83\x98\xf0\x9f\x83\x99\xf0\x9f\x83\x9a\xf0\x9f\x83\x9b\xf0\x9f\x83\x9c\xf0\x9f\x83\x9d\xf0\x9f\x83\x9e'
>>> blob_service.get_blob_to_bytes('test', 'deck.txt', start_range=0, end_range=1).content
b'\xf0\x9f'
>>> blob_service.get_blob_to_bytes('test', 'deck.txt', start_range=1, end_range=1).content
b'\x9f'
>>> blob_service.get_blob_to_bytes('test', 'deck.txt', start_range=0, end_range=0).content
b'\xf0\x9f\x82\xa1\xf0\x9f\x82\xa2\xf0\x9f\x82\xa3\xf0\x9f\x82\xa4\xf0\x9f\x82\xa5\xf0\x9f\x82\xa6\xf0\x9f\x82\xa7\xf0\x9f\x82\xa8\xf0\x9f\x82\xa9\xf0\x9f\x82\xaa\xf0\x9f\x82\xab\xf0\x9f\x82\xac\xf0\x9f\x82\xad\xf0\x9f\x82\xae\n\xf0\x9f\x82\xb1\xf0\x9f\x82\xb2\xf0\x9f\x82\xb3\xf0\x9f\x82\xb4\xf0\x9f\x82\xb5\xf0\x9f\x82\xb6\xf0\x9f\x82\xb7\xf0\x9f\x82\xb8\xf0\x9f\x82\xb9\xf0\x9f\x82\xba\xf0\x9f\x82\xbb\xf0\x9f\x82\xbc\xf0\x9f\x82\xbd\xf0\x9f\x82\xbe\n\xf0\x9f\x83\x81\xf0\x9f\x83\x82\xf0\x9f\x83\x83\xf0\x9f\x83\x84\xf0\x9f\x83\x85\xf0\x9f\x83\x86\xf0\x9f\x83\x87\xf0\x9f\x83\x88\xf0\x9f\x83\x89\xf0\x9f\x83\x8a\xf0\x9f\x83\x8b\xf0\x9f\x83\x8c\xf0\x9f\x83\x8d\xf0\x9f\x83\x8e\n\xf0\x9f\x83\x91\xf0\x9f\x83\x92\xf0\x9f\x83\x93\xf0\x9f\x83\x94\xf0\x9f\x83\x95\xf0\x9f\x83\x96\xf0\x9f\x83\x97\xf0\x9f\x83\x98\xf0\x9f\x83\x99\xf0\x9f\x83\x9a\xf0\x9f\x83\x9b\xf0\x9f\x83\x9c\xf0\x9f\x83\x9d\xf0\x9f\x83\x9e'
>>> 

Is this the intended behavior?

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions