Azure / Azure/azure-storage-python

BaseBlobService.get_blob_to_stream doesn't accept io.StringIO as a stream

Abierto
#536 3 comentarios 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
Python
Estrellas
343
Forks
243
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

### Which service(blob, file, queue) does this issue concern?

Blob

### Which version of the SDK was used? Please provide the output of `pip freeze`.

```
azure-storage-blob==1.4.0
azure-storage-common==1.4.0
azure-storage-file==1.4.0
azure-storage-nspkg==3.0.0
azure-storage-queue==1.4.0
```

### What problem was encountered?

```python
from azure.storage.blob.baseblobservice import BaseBlobService
import io

file_uri = "..."
blob_service = BaseBlobService(connection_string="...")

string_stream = io.StringIO()
string_result = blob_service.get_blob_to_stream("...", "....csv", stream=string_stream)
```

Fails with:
```
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
in ()
1 string_stream = io.StringIO()
----> 2 string_result = blob_service.get_blob_to_stream("...", ".....csv", stream=string_stream)
3 #print("content type: {}".format(type(string_stream)))

~/miniconda3/envs/py36/lib/python3.6/site-packages/azure/storage/blob/baseblobservice.py in get_blob_to_stream(self, container_name, blob_name, stream, snapshot, start_range, end_range, validate_content, progress_callback, max_connections, lease_id, if_modified_since, if_unmodified_since, if_match, if_none_match, timeout)
2052 # Clear blob content since output has been written to user stream
2053 if blob.content is not None:
-> 2054 stream.write(blob.content)
2055 blob.content = None
2056

TypeError: string argument expected, got 'bytes'
```

Even though accordin to the docs the [stream param](https://azure-storage.readthedocs.io/ref/azure.storage.blob.baseblobservice.html?highlight=get_blob_to_stream#azure.storage.blob.baseblobservice.BaseBlobService.get_blob_to_stream) is an `io.IOBase` and `issubclass(io.StringIO, io.IOBase)` is `True`.
Am I missing something?

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.