<jupyter_start><jupyter_text>Before you beginFor this code to work, you need to have set the option to add Minio credentials when you started the server![Minio Credentials Option](kubeflow-minio-option.png) Upload and download files from Bucket Storage!Many of these examples are straight from the Minio Python SDK.The difference is that instead of creating your own MinioClient object,you can just and run```pythonimport daaas_storageminio_client = daaas_storage.get_minimal_client()```Then you proceed as in the examples!  Get connected<jupyter_code>import daaas_storage
import os
#minio_client = daaas_storage.get_minimal_client()
minio_client = daaas_storage.get_premium_client()
#minio_client = daaas_storage.get_pachyderm_client()<jupyter_output><empty_output><jupyter_text>Create your bucket<jupyter_code># Your bucket goes here.
BUCKET = 'blair-drummond'
if not minio_client.bucket_exists(BUCKET):
    # ignore the location. It's a dummy value. But you do need it.
    minio_client.make_bucket(BUCKET, location="us-west-1")
else:
    print("Your bucket already exists.")<jupyter_output><empty_output><jupyter_text>Upload a file<jupyter_code>from progress import Progress
from minio.error import ResponseError

FILE='example.txt'

# Notice that it is "in a folder", but we didn't make a folder
# That's because object storage doesn't have folders. You, just
# put a slash in the name to "see a folder" in the GUI
NEW_FILE_NAME='examples/Happy-DAaaS-Bird.txt'

# Upload a file with progress.
progress = Progress()
try:
    with open(FILE, 'rb') as file_data:
        file_stat = os.stat(FILE)
        minio_client.put_object(
            BUCKET, 
            NEW_FILE_NAME,
            file_data,
            file_stat.st_size, 
            progress=progress
        )
except ResponseError as err:
    print(err)<jupyter_output><empty_output><jupyter_text>List Objects<jupyter_code># List all object paths in bucket that begin with my-prefixname.
# Prefixes are basically how you select folders.
objects = minio_client.list_objects(
    BUCKET, 
    prefix='examples/',
    recursive=True
)

for obj in objects:
    print(obj.bucket_name, obj.object_name.encode('utf-8'), obj.last_modified,
          obj.etag, obj.size, obj.content_type)<jupyter_output><empty_output><jupyter_text>Download a file<jupyter_code># Get a full object
try:
    data = minio_client.get_object(BUCKET, NEW_FILE_NAME)
    with open("downloaded_file.txt", 'wb') as file_data:
        for d in data.stream(32*1024):
            file_data.write(d)
except ResponseError as err:
    print(err)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.08653846153846154, 'fraction_numerical': 0.003076923076923077, 'mean_word_length': 4.5576923076923075, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '349647', 'license': 'MIT', 'n_tokens_mistral': 858, 'n_tokens_neox': 833, 'n_words': 235, 'path': 'self-serve-storage/python/Storage Examples.ipynb', 'repo_name': 'chritter/jupyter-notebooks', 'size': '2600'}