|
| 1 | +# Copyright (c) Microsoft Corporation. All rights reserved. |
| 2 | +# Licensed under the MIT License. |
| 3 | + |
| 4 | +from typing import Optional |
| 5 | + |
| 6 | +from azure.functions import _abc as azf_abc |
| 7 | + |
| 8 | + |
| 9 | +class InputStream(azf_abc.InputStream): |
| 10 | + """An InputStream object. |
| 11 | +
|
| 12 | + :param str name: |
| 13 | + An optional str specifying the name of the blob. |
| 14 | + |
| 15 | + :param str uri: |
| 16 | + An optional str specifying the uri of the blob. |
| 17 | + |
| 18 | + :param str length: |
| 19 | + An optional int specifying the length of the blob. |
| 20 | + """ |
| 21 | + def __init__(self, *, |
| 22 | + name: Optional[str] = None, |
| 23 | + uri: Optional[str] = None, |
| 24 | + length: Optional[int] = None) -> None: |
| 25 | + self._name = name |
| 26 | + self._length = length |
| 27 | + self._uri = uri |
| 28 | + |
| 29 | + @property |
| 30 | + def name(self) -> Optional[str]: |
| 31 | + """The name of the blob.""" |
| 32 | + return self._name |
| 33 | + |
| 34 | + @property |
| 35 | + def length(self) -> Optional[int]: |
| 36 | + """The size of the blob in bytes.""" |
| 37 | + return self._length |
| 38 | + |
| 39 | + @property |
| 40 | + def uri(self) -> Optional[str]: |
| 41 | + """The blob's primary location URI.""" |
| 42 | + return self._uri |
| 43 | + |
| 44 | + |
| 45 | + def read(self, size=-1) -> bytes: |
| 46 | + """Return and read up to *size* bytes. |
| 47 | +
|
| 48 | + :param int size: |
| 49 | + The number of bytes to read. If the argument is omitted, |
| 50 | + ``None``, or negative, data is read and returned until |
| 51 | + EOF is reached. |
| 52 | +
|
| 53 | + :return: |
| 54 | + Bytes read from the input stream. |
| 55 | + """ |
| 56 | + return self._io.read(size) |
0 commit comments