Evertime i am getting same error why?

Traceback (most recent call last):
File “/home/msis/.local/lib/python3.10/site-packages/streamlit/runtime/scriptrunner/script_runner.py”, line 535, in _run_script
exec(code, module.dict)
File “/home/msis/newminio_demo.py”, line 70, in
main()
File “/home/msis/newminio_demo.py”, line 48, in main
minio_client = connect_to_minio(endpoint_url, access_key, secret_key)
File “/home/msis/newminio_demo.py”, line 8, in connect_to_minio
client = Minio(endpoint_url,
File “/home/msis/.local/lib/python3.10/site-packages/minio/api.py”, line 152, in init
self._base_url = BaseURL(
File “/home/msis/.local/lib/python3.10/site-packages/minio/helpers.py”, line 541, in init
url = _parse_url(endpoint)
File “/home/msis/.local/lib/python3.10/site-packages/minio/helpers.py”, line 502, in _parse_url
raise ValueError(“path in endpoint is not allowed”

If I had to guess I would say because your endpoint_url is wrong.

import streamlit as st
from minio import Minio
from minio.error import S3Error

Function to connect to MinIO server

def connect_to_minio(endpoint_url, access_key, secret_key):
try:
client = Minio(endpoint_url,
access_key=access_key,
secret_key=secret_key,
secure=False) # Using HTTP, set to True if using HTTPS
return client
except S3Error as e:
st.error(f"Error: {e}")
return None

Function to list buckets

def list_buckets(minio_client):
try:
buckets = minio_client.list_buckets()
return [bucket.name for bucket in buckets]
except S3Error as e:
st.error(f"Error: {e}")
return

Function to list objects in a bucket

def list_objects(minio_client, bucket_name):
try:
objects = minio_client.list_objects(bucket_name, recursive=True)
return [obj.object_name for obj in objects]
except S3Error as e:
st.error(f"Error: {e}")
return

Main function to run the Streamlit app

def main():
st.title(“MinIO Explorer”)

# Sidebar for MinIO server connection details
st.sidebar.header("MinIO Connection")
endpoint_url = st.sidebar.text_input("MinIO Endpoint URL", "")
access_key = st.sidebar.text_input("Access Key", "")
secret_key = st.sidebar.text_input("Secret Key", "", type="password")
connect_button = st.sidebar.button("Connect to MinIO")

if connect_button:
    # Connect to MinIO server
    minio_client = connect_to_minio(endpoint_url, access_key, secret_key)
    
    if minio_client:
        st.sidebar.success("Connected to MinIO")
        
        # Display buckets
        st.subheader("Buckets")
        buckets = list_buckets(minio_client)
        if buckets:
            selected_bucket = st.selectbox("Select a bucket", buckets)
            
            # Display objects in selected bucket
            st.subheader(f"Objects in {selected_bucket}")
            objects = list_objects(minio_client, selected_bucket)
            for obj in objects:
                st.write(obj)
        else:
            st.warning("No buckets found.")
    else:
        st.error("Failed to connect to MinIO")

if name == “main”:
main()
like my code is working but why it shows error can one help me to find out the problem

Make sure endpoint_url is the URL of the target service.

my enpoint url is http://172.16.51.21:9000 i gave in streamlit webapplication but still iam facing issue

I am puzzled, that url should not raise that error. I even gave it to the function _parse_url mentioned in the traceback and it ran without issues. Sorry, I am out of ideas.

  • The ip is not reachable?
  • Insecure connection via http not permitted?