A file to upload:: >>> Upload('filename.txt', 'data', 'application/octet-stream') >>> Upload('filename.txt', 'data') >>> Upload("README.txt") :param filename: Name of the
| 13 | |
| 14 | |
| 15 | class Upload: |
| 16 | """ |
| 17 | A file to upload:: |
| 18 | |
| 19 | >>> Upload('filename.txt', 'data', 'application/octet-stream') |
| 20 | <Upload "filename.txt"> |
| 21 | >>> Upload('filename.txt', 'data') |
| 22 | <Upload "filename.txt"> |
| 23 | >>> Upload("README.txt") |
| 24 | <Upload "README.txt"> |
| 25 | |
| 26 | :param filename: Name of the file to upload. |
| 27 | :param content: Contents of the file. |
| 28 | :param content_type: MIME type of the file. |
| 29 | |
| 30 | """ |
| 31 | |
| 32 | def __init__(self, filename, content=None, content_type=None): |
| 33 | self.filename = filename |
| 34 | self.content = content |
| 35 | self.content_type = content_type |
| 36 | |
| 37 | def __iter__(self): |
| 38 | yield self.filename |
| 39 | if self.content is not None: |
| 40 | yield self.content |
| 41 | yield self.content_type |
| 42 | # TODO: do we handle the case when we need to get |
| 43 | # contents ourselves? |
| 44 | |
| 45 | def __repr__(self): |
| 46 | return '<Upload "%s">' % self.filename |
| 47 | |
| 48 | |
| 49 | class Field: |
no outgoing calls
searching dependent graphs…