Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add type hint for Minio.put_object #1301

Merged
merged 5 commits into from
Sep 24, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 19 additions & 7 deletions minio/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
Simple Storage Service (aka S3) client to perform bucket and object operations.
"""

from __future__ import absolute_import
from __future__ import absolute_import, annotations

import itertools
import os
Expand All @@ -31,6 +31,7 @@
from io import BytesIO
from random import random
from threading import Thread
from typing import BinaryIO
from urllib.parse import urlunsplit
from xml.etree import ElementTree as ET

Expand Down Expand Up @@ -61,7 +62,7 @@
from .retention import Retention
from .select import SelectObjectReader, SelectRequest
from .signer import presign_v4, sign_v4_s3
from .sse import SseCustomerKey
from .sse import Sse, SseCustomerKey
from .sseconfig import SSEConfig
from .tagging import Tagging
from .versioningconfig import VersioningConfig
Expand Down Expand Up @@ -1604,11 +1605,22 @@ def _upload_part_task(self, args):
"""Upload_part task for ThreadPool."""
return args[5], self._upload_part(*args)

def put_object(self, bucket_name, object_name, data, length,
content_type="application/octet-stream",
metadata=None, sse=None, progress=None,
part_size=0, num_parallel_uploads=3,
tags=None, retention=None, legal_hold=False):
def put_object(
self,
bucket_name: str,
object_name: str,
data: BinaryIO,
length: int,
content_type: str = "application/octet-stream",
metadata: dict[str, str] | None = None,
sse: Sse | None = None,
progress: Thread | None = None,
part_size: int = 0,
num_parallel_uploads: int = 3,
tags: Tags | None = None,
retention: Retention | None = None,
legal_hold: bool = False
) -> ObjectWriteResult:
"""
Uploads data from a stream to an object in a bucket.

Expand Down