Constructor. Args: fd: io.Base or file object, The source of the bytes to upload. MUST be opened in blocking mode, do not use streams opened in non-blocking mode. The given stream must be seekable, that is, it must be able to call seek() on fd.
(self, fd, mimetype, chunksize=DEFAULT_CHUNK_SIZE, resumable=False)
| 450 | |
| 451 | @util.positional(3) |
| 452 | def __init__(self, fd, mimetype, chunksize=DEFAULT_CHUNK_SIZE, resumable=False): |
| 453 | """Constructor. |
| 454 | |
| 455 | Args: |
| 456 | fd: io.Base or file object, The source of the bytes to upload. MUST be |
| 457 | opened in blocking mode, do not use streams opened in non-blocking mode. |
| 458 | The given stream must be seekable, that is, it must be able to call |
| 459 | seek() on fd. |
| 460 | mimetype: string, Mime-type of the file. |
| 461 | chunksize: int, File will be uploaded in chunks of this many bytes. Only |
| 462 | used if resumable=True. Pass in a value of -1 if the file is to be |
| 463 | uploaded as a single chunk. Note that Google App Engine has a 5MB limit |
| 464 | on request size, so you should never set your chunksize larger than 5MB, |
| 465 | or to -1. |
| 466 | resumable: bool, True if this is a resumable upload. False means upload |
| 467 | in a single request. |
| 468 | """ |
| 469 | super(MediaIoBaseUpload, self).__init__() |
| 470 | self._fd = fd |
| 471 | self._mimetype = mimetype |
| 472 | if not (chunksize == -1 or chunksize > 0): |
| 473 | raise InvalidChunkSizeError() |
| 474 | self._chunksize = chunksize |
| 475 | self._resumable = resumable |
| 476 | |
| 477 | self._fd.seek(0, os.SEEK_END) |
| 478 | self._size = self._fd.tell() |
| 479 | |
| 480 | def chunksize(self): |
| 481 | """Chunk size for resumable uploads. |
nothing calls this directly
no test coverage detected