Skip to content

Commit

Permalink
fix data argument description of put_object() API (#1071)
Browse files Browse the repository at this point in the history
Fixes #1070
  • Loading branch information
balamurugana authored Jan 29, 2021
1 parent 014651b commit 36453d8
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 18 deletions.
28 changes: 14 additions & 14 deletions docs/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -1115,20 +1115,20 @@ Uploads data from a stream to an object in a bucket.

__Parameters__

| Param | Type | Description |
|:---------------|:---------------|:--------------------------------------------------------------------|
| `bucket_name` | _str_ | Name of the bucket. |
| `object_name` | _str_ | Object name in the bucket. |
| `data` | _io.RawIOBase_ | Contains object data. |
| `length` | _int_ | Data size; -1 for unknown size and set valid part_size. |
| `content_type` | _str_ | Content type of the object. |
| `metadata` | _dict_ | Any additional metadata to be uploaded along with your PUT request. |
| `sse` | _Sse_ | Server-side encryption. |
| `progress` | _threading_ | A progress object. |
| `part_size` | _int_ | Multipart part size. |
| `tags` | _Tags_ | Tags for the object. |
| `retention` | _Retention_ | Retention configuration. |
| `legal_hold` | _bool_ | Flag to set legal hold for the object. |
| Param | Type | Description |
|:---------------|:------------|:--------------------------------------------------------------------|
| `bucket_name` | _str_ | Name of the bucket. |
| `object_name` | _str_ | Object name in the bucket. |
| `data` | _object_ | An object having callable read() returning bytes object. |
| `length` | _int_ | Data size; -1 for unknown size and set valid part_size. |
| `content_type` | _str_ | Content type of the object. |
| `metadata` | _dict_ | Any additional metadata to be uploaded along with your PUT request. |
| `sse` | _Sse_ | Server-side encryption. |
| `progress` | _threading_ | A progress object. |
| `part_size` | _int_ | Multipart part size. |
| `tags` | _Tags_ | Tags for the object. |
| `retention` | _Retention_ | Retention configuration. |
| `legal_hold` | _bool_ | Flag to set legal hold for the object. |

__Return Value__

Expand Down
8 changes: 4 additions & 4 deletions minio/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1657,7 +1657,7 @@ def put_object(self, bucket_name, object_name, data, length,
:param bucket_name: Name of the bucket.
:param object_name: Object name in the bucket.
:param data: Contains object data.
:param data: An object having callable read() returning bytes object.
:param length: Data size; -1 for unknown size and set valid part_size.
:param content_type: Content type of the object.
:param metadata: Any additional metadata to be uploaded along
Expand All @@ -1674,12 +1674,12 @@ def put_object(self, bucket_name, object_name, data, length,
Example::
# Upload data.
result = client.put_object(
"my-bucket", "my-object", io.StringIO("hello"), 5,
"my-bucket", "my-object", io.BytesIO(b"hello"), 5,
)
# Upload data with metadata.
result = client.put_object(
"my-bucket", "my-object", io.StringIO("hello"), 5,
"my-bucket", "my-object", io.BytesIO(b"hello"), 5,
metadata={"My-Project": "one"},
)
Expand All @@ -1690,7 +1690,7 @@ def put_object(self, bucket_name, object_name, data, length,
tags = Tags(for_object=True)
tags["User"] = "jsmith"
result = client.put_object(
"my-bucket", "my-object", io.StringIO("hello"), 5,
"my-bucket", "my-object", io.BytesIO(b"hello"), 5,
tags=tags,
retention=Retention(GOVERNANCE, date),
legal_hold=True,
Expand Down
2 changes: 2 additions & 0 deletions minio/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ def read_part_data(stream, size, part_data=b'', progress=None):
data = stream.read(bytes_to_read)
if not data:
break # EOF reached
if not isinstance(data, bytes):
raise ValueError("read() must return 'bytes' object")
part_data += data
if progress:
progress.update(len(data))
Expand Down

0 comments on commit 36453d8

Please sign in to comment.