I want to use python to store and download file in minio
Below is the code
from minio import Minio
import os
def getMinioClient(access, secret):
return Minio(
endpoint="localhost:9000",
access_key=access,
secret_key=secret,
secure=False,
)
if __name__ == "__main__":
client = getMinioClient("admin", "Secret_key123")
try:
file_name = "myfile.csv"
bucket = "file_bucket"
with open(file_name, "rb") as f:
stat_data = os.stat(file_name)
# fput_object to upload file
a = client.fput_object(
bucket,
file_name,
f,
stat_data.st_size
)
print("uploaded")
# using fget_object to download file
client.fget_object(bucket, file_name, f"{file_name}_downloaded")
except Exception as e:
print(e)
Only option I know to download file is using fget_object
How can I get a link, which upon pasted in url bar get the required file downloaded
Just like link which we get from minio UI, when we click on share of particular file like below
After clicking on share link, a link is generated which can be used to download that file without even logging in.
How will I be able to generate the download link from within python code by making connection to minio.
Thanks in advance!