Maintainers
Pricing
Enterprise
More
More
Documentation
Try Live
Rankings
Install
Blog
Docs7
Ask
New
Add Docs
Miniopy Async
https://hlf20010508.github.io/miniopy-async/
Admin
Miniopy Async is an asynchronous MinIO Client SDK for Python.
Tokens:
176,778
Snippets:
978
Trust Score:
9.7
Update:
1 week ago
Context
Chat
Benchmark
89.8
Latest
Show doc for...
Code
Info
Show Results
Tokens:
Raw
Copy
Link
Tokens:
Raw
Copy
Link
### Get bucket replication example Source: https://hlf20010508.github.io/miniopy-async/_modules/miniopy_async/api.html Shows how to retrieve the replication configuration for a bucket and print it. Returns a ReplicationConfig object or None if not found. ```python from miniopy_async import Minio import asyncio async def main(): async with Minio( "play.min.io", access_key="Q3AM3UQ867SPQQA43P2F", secret_key="zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG", secure=True # http for False, https for True ) as client: config = await client.get_bucket_replication("my-bucket") print(config) asyncio.run(main()) ``` -------------------------------- ### Get bucket versioning example Source: https://hlf20010508.github.io/miniopy-async/_modules/miniopy_async/api.html Example usage of get_bucket_versioning to retrieve and print the versioning status of a bucket. ```python from miniopy_async import Minio import asyncio async def main(): async with Minio( "play.min.io", access_key="Q3AM3UQ867SPQQA43P2F", secret_key="zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG", secure=True, # http for False, https for True ) as client: config = await client.get_bucket_versioning("my-bucket") print(config.status) asyncio.run(main()) ``` -------------------------------- ### Create async MinIO client and list buckets Source: https://hlf20010508.github.io/miniopy-async/generated/miniopy_async.html Quickstart example showing how to create an asynchronous MinIO client using the `miniopy_async` package and list all buckets. Uses the public Play server with credentials, and `asyncio.run()` to execute the asynchronous `list_buckets()` call. ```python >>> from miniopy_async import Minio >>> import asyncio >>> client = Minio( ... "play.min.io", ... access_key="Q3AM3UQ867SPQQA43P2F", ... secret_key="zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG", ... secure=True # http for False, https for True ... ) >>> buckets = asyncio.run( ... client.list_buckets() ... ) >>> for bucket in buckets: ... print(bucket.name, bucket.creation_date) ``` -------------------------------- ### presigned_put_object example Source: https://hlf20010508.github.io/miniopy-async/_modules/miniopy_async/api.html Shows how to get a presigned URL for uploading an object. Includes examples with default expiry and a custom two-hour expiry. ```python from datetime import timedelta from miniopy_async import Minio import asyncio async def main(): client = Minio( "play.min.io", access_key="Q3AM3UQ867SPQQA43P2F", secret_key="zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG", secure=True # http for False, https for True ) # Get presigned URL string to upload data to 'my-object' in # 'my-bucket' with default expiry (i.e. 7 days). url = await client.presigned_put_object("my-bucket", "my-object") print('url:', url) # Get presigned URL string to upload data to 'my-object' in # 'my-bucket' with two hours expiry. url = await client.presigned_put_object( "my-bucket", "my-object", expires=timedelta(hours=2), ) print('url:', url) asyncio.run(main()) ``` -------------------------------- ### presigned_post_policy example Source: https://hlf20010508.github.io/miniopy-async/_modules/miniopy_async/api.html Shows how to get form-data for a PostPolicy to upload an object using POST. Includes creating a policy with conditions and generating a curl command. ```python from datetime import datetime, timedelta from miniopy_async import Minio from miniopy_async.datatypes import PostPolicy import asyncio async def main(): async with Minio( "play.min.io", access_key="Q3AM3UQ867SPQQA43P2F", secret_key="zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG", secure=True # http for False, https for True ) as client: policy = PostPolicy( "my-bucket", datetime.utcnow() + timedelta(days=10), ) policy.add_starts_with_condition("key", "my/object/prefix/") policy.add_content_length_range_condition(1*1024*1024, 10*1024*1024) form_data = await client.presigned_post_policy(policy) curl_cmd = ( "curl -X POST " "https://play.min.io/my-bucket " "{0} -F file=@<FILE>" ).format( " ".join(["-F {0}={1}".format(k, v) for k, v in form_data.items()]), ) print('curl_cmd:',curl_cmd) asyncio.run(main()) ``` -------------------------------- ### make_bucket example Source: https://hlf20010508.github.io/miniopy-async/_modules/miniopy_async/api.html Example for creating buckets with optional region and object lock. Shows three variations: default, specific region, and with object lock. ```python from miniopy_async import Minio import asyncio async def main(): async with Minio( "play.min.io", access_key="Q3AM3UQ867SPQQA43P2F", secret_key="zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG", secure=True, ) as client: # Create bucket. print('example one') await client.make_bucket("my-bucket1") # Create bucket on specific region. print('example two') await client.make_bucket("my-bucket2", "us-east-1") # Create bucket with object-lock feature on specific region. print('example three') await client.make_bucket("my-bucket3", "us-east-1", object_lock=True) asyncio.run(main()) ``` -------------------------------- ### Example usage of presigned_get_object for download Source: https://hlf20010508.github.io/miniopy-async/_modules/miniopy_async/api.html Shows how to generate a presigned URL for downloading an object using the presigned_get_object method. Includes examples for default expiry and custom expiry. ```python from datetime import timedelta from miniopy_async import Minio import asyncio async def main(): client = Minio( "play.min.io", access_key="Q3AM3UQ867SPQQA43P2F", secret_key="zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG", secure=True # http for False, https for True ) # Get presigned URL string to download 'my-object' in # 'my-bucket' with default expiry (i.e. 7 days). print('example one') url = await client.presigned_get_object("my-bucket", "my-object") print('url:', url) # Get presigned URL string to download 'my-object' in # 'my-bucket' with two hours expiry. print('example two') url = await client.presigned_get_object( "my-bucket", "my-object", expires=timedelta(hours=2), ) print('url:', url) ``` -------------------------------- ### Set bucket replication example Source: https://hlf20010508.github.io/miniopy-async/_modules/miniopy_async/api.html Shows how to set a replication configuration for a bucket. Requires a ReplicationConfig object with a role ARN and destination bucket ARN. The example includes creating bucket tags and a rule with a filter. ```python from miniopy_async import Minio from miniopy_async.commonconfig import DISABLED, ENABLED, AndOperator, Filter, Tags from miniopy_async.replicationconfig import (DeleteMarkerReplication, Destination, ReplicationConfig, Rule) import asyncio async def main(): async with Minio( "play.min.io", access_key="Q3AM3UQ867SPQQA43P2F", secret_key="zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG", secure=True # http for False, https for True ) as client: bucket_tags = Tags.new_bucket_tags() bucket_tags["Project"] = "Project One" bucket_tags["User"] = "jsmith" config = ReplicationConfig( "REPLACE-WITH-ACTUAL-ROLE", [ Rule( Destination( "REPLACE-WITH-ACTUAL-DESTINATION-BUCKET-ARN", ), ENABLED, delete_marker_replication=DeleteMarkerReplication( DISABLED, ), rule_filter=Filter( AndOperator( "TaxDocs", bucket_tags, ), ), rule_id="rule1", priority=1, ), ], ) async def main(): await client.set_bucket_replication("my-bucket", config) asyncio.run(main()) ``` -------------------------------- ### Set bucket versioning example Source: https://hlf20010508.github.io/miniopy-async/_modules/miniopy_async/api.html Example usage of set_bucket_versioning to enable versioning on a bucket. Uses VersioningConfig with ENABLED. ```python from miniopy_async import Minio from miniopy_async.commonconfig import ENABLED from miniopy_async.versioningconfig import VersioningConfig import asyncio async def main(): async with Minio( "play.min.io", access_key="Q3AM3UQ867SPQQA43P2F", secret_key="zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG", secure=True, # http for False, https for True ) as client: await client.set_bucket_versioning("my-bucket", VersioningConfig(ENABLED)) asyncio.run(main()) ``` -------------------------------- ### Example usage of get_presigned_url for upload and download Source: https://hlf20010508.github.io/miniopy-async/_modules/miniopy_async/api.html Shows how to generate presigned URLs for uploading and downloading objects using the get_presigned_url method. Includes examples for setting response headers and custom expiry times. ```python # Get presigned URL string to upload 'my-object' in # 'my-bucket' with response-content-type as application/json # and one day expiry. print('example two') url = await client.get_presigned_url( "PUT", "my-bucket", "my-object", expires=timedelta(days=1), response_headers={"response-content-type": "application/json"}, ) print('url:', url) # Get presigned URL string to download 'my-object' in # 'my-bucket' with two hours expiry. print('example three') url = await client.get_presigned_url( "GET", "my-bucket", "my-object", expires=timedelta(hours=2), ) print('url:', url) asyncio.run(main()) ``` -------------------------------- ### Copy object examples using miniopy_async Source: https://hlf20010508.github.io/miniopy-async/_modules/miniopy_async/api.html Example usage of the copy_object method from the miniopy_async library, demonstrating basic copy, copy with condition, and copy with metadata replacement. ```python from datetime import datetime, timezone from miniopy_async import Minio from miniopy_async.commonconfig import REPLACE, CopySource import asyncio async def main(): async with Minio( "play.min.io", access_key="Q3AM3UQ867SPQQA43P2F", secret_key="zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG", secure=True, # http for False, https for True ) as client: # copy an object from a bucket to another. print("example one") result = await client.copy_object( "my-job-bucket", "my-copied-object1", CopySource("my-bucket", "my-object"), ) print(result.object_name, result.version_id) # copy an object with condition. print("example two") result = await client.copy_object( "my-job-bucket", "my-copied-object2", CopySource( "my-bucket", "my-object", modified_since=datetime(2014, 4, 1, tzinfo=timezone.utc), ), ) print(result.object_name, result.version_id) # copy an object from a bucket with replacing metadata. print("example three") metadata = {"Content-Type": "application/octet-stream"} result = await client.copy_object( "my-job-bucket", "my-copied-object3", CopySource("my-bucket", "my-object"), metadata=metadata, metadata_directive=REPLACE, ) print(result.object_name, result.version_id) asyncio.run(main()) ``` -------------------------------- ### Get bucket policy with get_bucket_policy Source: https://hlf20010508.github.io/miniopy-async/_modules/miniopy_async/api.html Example usage of the get_bucket_policy method to retrieve the bucket policy configuration as a JSON string and print it. ```python from miniopy_async import Minio import asyncio async def main(): async with Minio( "play.min.io", access_key="Q3AM3UQ867SPQQA43P2F", secret_key="zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG", secure=True, # http for False, https for True ) as client: policy = await client.get_bucket_policy("my-bucket") print(policy) asyncio.run(main()) ``` -------------------------------- ### Generate presigned GET URL with miniopy_async Source: https://hlf20010508.github.io/miniopy-async/generated/miniopy_async.html Shows how to generate a presigned GET URL for downloading an object with default 7-day expiry and a custom 2-hour expiry. Requires a MinIO client with valid credentials; the URL is printed. ```python from datetime import timedelta from miniopy_async import Minio import asyncio async def main(): client = Minio( "play.min.io", access_key="Q3AM3UQ867SPQQA43P2F", secret_key="zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG", secure=True # http for False, https for True ) # Get presigned URL string to download 'my-object' in # 'my-bucket' with default expiry (i.e. 7 days). print('example one') url = await client.presigned_get_object("my-bucket", "my-object") print('url:', url) # Get presigned URL string to download 'my-object' in # 'my-bucket' with two hours expiry. print('example two') url = await client.presigned_get_object( "my-bucket", "my-object", expires=timedelta(hours=2), ) print('url:', url) asyncio.run(main()) ``` -------------------------------- ### info method Source: https://hlf20010508.github.io/miniopy-async/_modules/miniopy_async/minioadmin.html Gets MinIO server information by sending a GET request. Returns the response text. ```python async def info(self) -> str: """Get MinIO server information.""" response = await self._url_open( "GET", _COMMAND.INFO, ) return await response.text() ``` -------------------------------- ### Parallel multipart upload example Source: https://hlf20010508.github.io/miniopy-async/_modules/miniopy_async/api.html Shows how to use the multipart_uploader context manager to upload parts in parallel with asyncio.gather. The example uploads 10 parts of 1 MiB each and prints the resulting object name, etag, and version-id. ```python # Parallel upload print("example four") tasks = [] async with client.multipart_uploader( "my-bucket", "my-object", ) as uploader: for i in range(1, 11): data = (f"part{i}" * 1024 * 1024).encode("utf-8") tasks.append(uploader.upload_part(data, i)) await asyncio.gather(*tasks) result = uploader.result print( "created {0} object; etag: {1}, version-id: {2}".format( result.object_name, result.etag, result.version_id, ), ) asyncio.run(main()) ``` -------------------------------- ### Async Minio put_object with SSE, metadata, tags, retention, and legal-hold Source: https://hlf20010508.github.io/miniopy-async/generated/miniopy_async.html Complete example of using the async Minio client to upload objects with various options: plain, unknown size, content-type, metadata, SSE (customer key, KMS, S3), and tags/retention/legal-hold. Uses the play.min.io endpoint with credentials included. Each variant is printed with 'example one' through 'example eight'. ```python import io from datetime import datetime, timedelta from urllib.request import urlopen from miniopy_async import Minio from miniopy_async.commonconfig import GOVERNANCE, Tags from miniopy_async.retention import Retention from miniopy_async.sse import SseCustomerKey, SseKMS, SseS3 import asyncio async def main(): async with Minio( "play.min.io", access_key="Q3AM3UQ867SPQQA43P2F", secret_key="zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG", secure=True # http for False, https for True ) as client: # Upload data. print('example one') await client.put_object( "my-bucket", "my-object", io.BytesIO(b"hello"), 5, ) # Upload unknown sized data. print('example two') data = urlopen( "https://raw.githubusercontent.com/hlf20010508/miniopy -async/master/README.md", ) await client.put_object( "my-bucket", "my-object", data, length=-1, part_size=10*1024*1024, ) # Upload data with content-type. print('example three') await client.put_object( "my-bucket", "my-object", io.BytesIO(b"hello"), 5, content_type="application/csv", ) # Upload data with metadata. print('example four') await client.put_object( "my-bucket", "my-object", io.BytesIO(b"hello"), 5, metadata={"Content-Type": "application/octet-stream"}, ) # Upload data with customer key type of server-side encryption. print('example five') await client.put_object( "my-bucket", "my-object", io.BytesIO(b"hello"), 5, sse=SseCustomerKey(b"32byteslongsecretkeymustprovided"), ) # Upload data with KMS type of server-side encryption. print('example six') await client.put_object( "my-bucket", "my-object", io.BytesIO(b"hello"), 5, sse=SseKMS("KMS-KEY-ID", {"Key1": "Value1", "Key2": "Value2"}), ) # Upload data with S3 type of server-side encryption. print('example seven') await client.put_object( "my-bucket", "my-object", io.BytesIO(b"hello"), 5, sse=SseS3(), ) # Upload data with tags, retention and legal-hold. print('example eight') date = datetime.utcnow().replace( hour=0, minute=0, second=0, microsecond=0, ) + timedelta(days=30) tags = Tags(for_object=True) tags["User"] = "jsmith" await client.put_object( "my-bucket", "my-object", io.BytesIO(b"hello"), 5, tags=tags, retention=Retention(GOVERNANCE, date), legal_hold=True, ) asyncio.run(main()) ``` -------------------------------- ### fget_object example with version-ID and SSE-C Source: https://hlf20010508.github.io/miniopy-async/_modules/miniopy_async/api.html Example from the fget_object docstring showing how to download an object, download a specific version, and download an SSE-C encrypted object. It uses SseCustomerKey and asyncio.run. ```python from miniopy_async import Minio from miniopy_async.sse import SseCustomerKey import asyncio async def main(): async with Minio( "play.min.io", access_key="Q3AM3UQ867SPQQA43P2F", secret_key="zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG", secure=True, # http for False, https for True ) as client: # Download data of an object. print("example one") await client.fget_object("my-bucket", "my-object", "my-filename") # Download data of an object of version-ID. print("example two") await client.fget_object( "my-bucket", "my-object", "my-filename", version_id="dfbd25b3-abec-4184-a4e8-5a35a5c1174d", ) # Download data of an SSE-C encrypted object. print("example three") await client.fget_object( "my-bucket", "my-object", "my-filename", ssec=SseCustomerKey(b"32byteslongsecretkeymustprovided"), ) asyncio.run(main()) ``` -------------------------------- ### Set bucket tags example Source: https://hlf20010508.github.io/miniopy-async/_modules/miniopy_async/api.html Example usage of set_bucket_tags method. Creates a Tags object, sets key-value pairs, and applies them to a bucket. ```python from miniopy_async import Minio from miniopy_async.commonconfig import Tags import asyncio async def main(): async with Minio( "play.min.io", access_key="Q3AM3UQ867SPQQA43P2F", secret_key="zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG", secure=True # http for False, https for True ) as client: tags = Tags.new_bucket_tags() tags["Project"] = "Project One" tags["User"] = "jsmith" await client.set_bucket_tags("my-bucket", tags) asyncio.run(main()) ``` -------------------------------- ### set_app_info example Source: https://hlf20010508.github.io/miniopy-async/_modules/miniopy_async/minioadmin.html Example usage of set_app_info to set a custom user agent with app name and version. Raises ValueError if app_name or app_version is empty. ```python client.set_app_info('my_app', '1.0.2') ``` -------------------------------- ### Get object with offset, version-id, and SSE-C Source: https://hlf20010508.github.io/miniopy-async/generated/miniopy_async.html Demonstrates getting an object with various options: basic, offset/length, version-ID, and SSE-C encryption. Requires a running MinIO server and valid credentials. The response must be read by the caller. ```python from miniopy_async import Minio from miniopy_async.sse import SseCustomerKey import asyncio async def main(): async with Minio( "play.min.io", access_key="Q3AM3UQ867SPQQA43P2F", secret_key="zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG", secure=True, # http for False, https for True ) as client: # Get data of an object. print("example one") _response = await client.get_object("my-bucket", "my-object") # Read data from response. # Get data of an object from offset and length. print("example two") _response = await client.get_object( "my-bucket", "my-object", offset=512, length=1024, ) # Read data from response. # Get data of an object of version-ID. print("example three") _response = await client.get_object( "my-bucket", "my-object", version_id="dfbd25b3-abec-4184-a4e8-5a35a5c1174d", ) # Read data from response. # Get data of an SSE-C encrypted object. print("example four") _response = await client.get_object( "my-bucket", "my-object", ssec=SseCustomerKey(b"32byteslongsecretkeymustprovided"), ) # Read data from response. asyncio.run(main()) ``` -------------------------------- ### Set Object Retention Example Source: https://hlf20010508.github.io/miniopy-async/_modules/miniopy_async/api.html Demonstrates setting a retention policy on an object using the set_object_retention method. Requires a MinIO client, a Retention configuration with a governance mode and a retention period. The example uses an async context manager and asyncio.run. ```python from datetime import datetime, timedelta from miniopy_async import Minio from miniopy_async.commonconfig import GOVERNANCE from miniopy_async.retention import Retention import asyncio async def main(): async with Minio( "play.min.io", access_key="Q3AM3UQ867SPQQA43P2F", secret_key="zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG", secure=True, # http for False, https for True ) as client: config = Retention( GOVERNANCE, datetime.utcnow() + timedelta(days=10) ) await client.set_object_retention("my-bucket", "my-object", config) asyncio.run(main()) ``` -------------------------------- ### info() Source: https://hlf20010508.github.io/miniopy-async/_modules/miniopy_async/minioadmin.html Gets MinIO server information. ```APIDOC ## info() ### Description Gets MinIO server information. ### Method GET ### Endpoint /command/info ### Parameters None. ### Response Returns a string response from the server. ``` -------------------------------- ### MinioAdmin.config_get() Source: https://hlf20010508.github.io/miniopy-async/generated/modules.html Gets the configuration of the MinIO server. ```APIDOC ## MinioAdmin.config_get() ### Description Gets the configuration of the MinIO server. ### Method config_get() ### Parameters None ### Response Returns the server configuration. ``` -------------------------------- ### Set bucket policy with anonymous read-only and read-write policies Source: https://hlf20010508.github.io/miniopy-async/_modules/miniopy_async/api.html Example for setting a bucket policy using set_bucket_policy. It shows two policy examples: anonymous read-only and anonymous read-write. Requires a Minio client with valid credentials. ```python import json from miniopy_async import Minio import asyncio async def main(): async with Minio( "play.min.io", access_key="Q3AM3UQ867SPQQA43P2F", secret_key="zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG", secure=True, # http for False, https for True ) as client: # Example anonymous read-only bucket policy. print("example one") policy = { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": {"AWS": "*"}, "Action": ["s3:GetBucketLocation", "s3:ListBucket"], "Resource": "arn:aws:s3:::my-bucket", }, { "Effect": "Allow", "Principal": {"AWS": "*"}, "Action": "s3:GetObject", "Resource": "arn:aws:s3:::my-bucket/*", }, ], } await client.set_bucket_policy("my-bucket", json.dumps(policy)) # Example anonymous read-write bucket policy. print("example two") policy = { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": {"AWS": "*"}, "Action": [ "s3:GetBucketLocation", "s3:ListBucket", "s3:ListBucketMultipartUploads", ], "Resource": "arn:aws:s3:::my-bucket", }, { "Effect": "Allow", "Principal": {"AWS": "*"}, "Action": [ "s3:GetObject", "s3:PutObject", "s3:DeleteObject", "s3:ListMultipartUploadParts", "s3:AbortMultipartUpload", ], "Resource": "arn:aws:s3:::my-bucket/images/*", }, ], } await client.set_bucket_policy("my-bucket", json.dumps(policy)) asyncio.run(main()) ``` -------------------------------- ### Get bucket tags example Source: https://hlf20010508.github.io/miniopy-async/_modules/miniopy_async/api.html Example usage of get_bucket_tags method. Retrieves and prints the tags of a bucket. ```python from miniopy_async import Minio import asyncio async def main(): async with Minio( "play.min.io", access_key="Q3AM3UQ867SPQQA43P2F", secret_key="zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG", secure=True # http for False, https for True ) as client: tags = await client.get_bucket_tags("my-bucket") print(tags) asyncio.run(main()) ``` -------------------------------- ### Minio Client Initialization and list_buckets Source: https://hlf20010508.github.io/miniopy-async/generated/miniopy_async.html Example showing how to create a Minio client and asynchronously list buckets. ```APIDOC ## Minio Client Initialization and list_buckets ### Description Create a Minio client instance and asynchronously list all buckets. ### Usage Example ```python from miniopy_async import Minio import asyncio client = Minio( "play.min.io", access_key="Q3AM3UQ867SPQQA43P2F", secret_key="zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG", secure=True # http for False, https for True ) buckets = asyncio.run(client.list_buckets()) for bucket in buckets: print(bucket.name, bucket.creation_date) ``` ### Parameters - **endpoint** (string) - Required - The MinIO server endpoint. - **access_key** (string) - Required - Access key for authentication. - **secret_key** (string) - Required - Secret key for authentication. - **secure** (bool) - Optional - Use HTTPS if True, HTTP if False. ### Return Value - **buckets** (list) - List of bucket objects, each with `name` and `creation_date` attributes. ``` -------------------------------- ### async _profile_start(profilers: tuple[str] = ()) -> str Source: https://hlf20010508.github.io/miniopy-async/generated/miniopy_async.html Runs a system profile. ```APIDOC ## async _profile_start(profilers: tuple[str] = ()) -> str ### Description Runs a system profile. ### Signature `async def _profile_start(profilers: tuple[str] = ()) -> str` ### Parameters - **profilers** (`tuple[str]`) - Optional - Profilers to run. ### Return Type `str` ``` -------------------------------- ### Get presigned URL example Source: https://hlf20010508.github.io/miniopy-async/_modules/miniopy_async/api.html Example usage of the get_presigned_url method to generate a presigned URL for deleting an object with a one-day expiry. ```python from datetime import timedelta from miniopy_async import Minio import asyncio async def main(): client = Minio( "play.min.io", access_key="Q3AM3UQ867SPQQA43P2F", secret_key="zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG", secure=True # http for False, https for True ) # Get presigned URL string to delete 'my-object' in # 'my-bucket' with one day expiry. print('example one') url = await client.get_presigned_url( "DELETE", "my-bucket", "my-object", expires=timedelta(days=1), ) print('url:', url) ``` -------------------------------- ### profile_start(profilers: tuple[str] = ()) -> str Source: https://hlf20010508.github.io/miniopy-async/_modules/miniopy_async/minioadmin.html Starts a system profile with the specified profilers. ```APIDOC ## profile_start ### Description Runs a system profile. ### Method POST ### Endpoint START_PROFILE (internal command) ### Query Parameters - **profilerType;** (str) - Optional - Comma-separated list of profiler types. ### Response Returns the response text as a string. ``` -------------------------------- ### Get object information with stat_object Source: https://hlf20010508.github.io/miniopy-async/_modules/miniopy_async/api.html Example from the stat_object docstring showing how to get object information, including version ID and SSE-C encryption. ```python from miniopy_async import Minio from miniopy_async.sse import SseCustomerKey import asyncio async def main(): async with Minio( "play.min.io", access_key="Q3AM3UQ867SPQQA43P2F", secret_key="zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG", secure=True, # http for False, https for True ) as client: # Get object information. print("example one") result = await client.stat_object("my-bucket", "my-object") print( "status: last-modified: {0}, size: {1}".format( result.last_modified, result.size, ), ) # Get object information of version-ID. print("example two") result = await client.stat_object( "my-bucket", "my-object", version_id="dfbd25b3-abec-4184-a4e8-5a35a5c1174d", ) print( "status: last-modified: {0}, size: {1}".format( result.last_modified, result.size, ), ) # Get SSE-C encrypted object information. print("example three") result = await client.stat_object( "my-bucket", "my-object", ssec=SseCustomerKey(b"32byteslongsecretkeymustprovided"), ) print( "status: last-modified: {0}, size: {1}".format( result.last_modified, result.size, ), ) asyncio.run(main()) ``` -------------------------------- ### Get object retention with get_object_retention Source: https://hlf20010508.github.io/miniopy-async/_modules/miniopy_async/api.html Retrieves the retention configuration for an object. The example prints the returned Retention object for 'my-object' in 'my-bucket'. ```python from miniopy_async import Minio import asyncio async def main(): async with Minio( "play.min.io", access_key="Q3AM3UQ867SPQQA43P2F", secret_key="zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG", secure=True, # http for False, https for True ) as client: config = await client.get_object_retention( "my-bucket", "my-object" ) print(config) asyncio.run(main()) ``` -------------------------------- ### Minio class docstring usage examples Source: https://hlf20010508.github.io/miniopy-async/_modules/miniopy_async/api.html Shows three ways to create a Minio client: anonymous access, with access/secret keys, and with region specification. ```python # Create client with anonymous access. client = Minio("play.min.io") # Create client with access and secret key. client = Minio("s3.amazonaws.com", "ACCESS-KEY", "SECRET-KEY") # Create client with access key and secret key with specific region. client = Minio( "play.minio.io:9000", access_key="Q3AM3UQ867SPQQA43P2F", secret_key="zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG", region="my-region", ) ``` -------------------------------- ### Get bucket notification configuration Source: https://hlf20010508.github.io/miniopy-async/_modules/miniopy_async/api.html Example for retrieving a bucket's notification configuration using get_bucket_notification. Prints the returned NotificationConfig object. ```python from miniopy_async import Minio import asyncio async def main(): async with Minio( "play.min.io", access_key="Q3AM3UQ867SPQQA43P2F", secret_key="zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG", secure=True, # http for False, https for True ) as client: config = await client.get_bucket_notification("my-bucket") print(config) asyncio.run(main()) ``` -------------------------------- ### List objects with miniopy_async Minio.list_objects Source: https://hlf20010508.github.io/miniopy-async/generated/miniopy_async.html Shows how to list objects in a bucket using client.list_objects with various parameters: defaults, prefix, recursive, and start_after. The code uses the async context manager of Minio and prints each object. Credentials and endpoint are for the public play.min.io server. ```python from miniopy_async import Minio import asyncio async def main(): async with Minio( "play.min.io", access_key="Q3AM3UQ867SPQQA43P2F", secret_key="zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG", secure=True, # http for False, https for True ) as client: # List objects information. print("example one") objects = await client.list_objects("my-bucket") for obj in objects: print("obj:", obj) # List objects information whose names starts with "my/prefix/". print("example two") objects = await client.list_objects("my-bucket", prefix="my/prefix/") for obj in objects: print("obj:", obj) async for obj in client.list_objects("my-bucket"): print("obj:", obj) # List objects information recursively. print("example three") objects = await client.list_objects("my-bucket", recursive=True) for obj in objects: print("obj:", obj) # List objects information recursively whose names starts with # "my/prefix/". print("example four") objects = await client.list_objects( "my-bucket", prefix="my/prefix/", recursive=True, ) for obj in objects: print("obj:", obj) # List objects information recursively after object name # "my/prefix/world/1". print("example five") objects = await client.list_objects( "my-bucket", recursive=True, start_after="my/prefix/world/1", ) for obj in objects: print("obj:", obj) asyncio.run(main()) ``` -------------------------------- ### Get bucket encryption configuration Source: https://hlf20010508.github.io/miniopy-async/_modules/miniopy_async/api.html Example for retrieving the server-side encryption configuration of a bucket using the get_bucket_encryption method. It prints the returned SSEConfig object. ```python from miniopy_async import Minio import asyncio async def main(): async with Minio( "play.min.io", access_key="Q3AM3UQ867SPQQA43P2F", secret_key="zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG", secure=True, # http for False, https for True ) as client: config = await client.get_bucket_encryption("my-bucket") print(config) asyncio.run(main()) ``` -------------------------------- ### Get object lock configuration with get_object_lock_config Source: https://hlf20010508.github.io/miniopy-async/_modules/miniopy_async/api.html Retrieves the object-lock configuration for a bucket. The example shows an async client connecting to play.min.io and printing the returned ObjectLockConfig. ```python from miniopy_async import Minio import asyncio async def main(): async with Minio( "play.min.io", access_key="Q3AM3UQ867SPQQA43P2F", secret_key="zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG", secure=True, # http for False, https for True ) as client: config = await client.get_object_lock_config("my-bucket") print(config) asyncio.run(main()) ``` -------------------------------- ### Get bucket lifecycle configuration Source: https://hlf20010508.github.io/miniopy-async/_modules/miniopy_async/api.html Retrieves the lifecycle configuration of a bucket. The example shows creating an async Minio client and calling get_bucket_lifecycle, then printing the returned config. ```python from miniopy_async import Minio import asyncio async def main(): async with Minio( "play.min.io", access_key="Q3AM3UQ867SPQQA43P2F", secret_key="zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG", secure=True # http for False, https for True ) as client: config = await client.get_bucket_lifecycle("my-bucket") print(config) asyncio.run(main()) ``` -------------------------------- ### Get object tags with miniopy_async Minio client Source: https://hlf20010508.github.io/miniopy-async/_modules/miniopy_async/api.html Example usage of the get_object_tags method. It retrieves tags for a specified object and prints them. Requires a Minio client connection and valid bucket/object names. ```python from miniopy_async import Minio import asyncio async def main(): async with Minio( "play.min.io", access_key="Q3AM3UQ867SPQQA43P2F", secret_key="zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG", secure=True # http for False, https for True ) as client: tags = await client.get_object_tags("my-bucket", "my-object") print(tags) asyncio.run(main()) ``` -------------------------------- ### user_info method Source: https://hlf20010508.github.io/miniopy-async/_modules/miniopy_async/minioadmin.html Gets information about a user by sending a GET request. ```python async def user_info(self, access_key: str) -> str: """Get information about user""" response = await self._url_open( "GET", _COMMAND.USER_INFO, query_params={"accessKey": access_key}, ) return await response.text() ```