Notebooks >> Scripts
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

53 lines
1.2 KiB

{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from minio import Minio\n",
"from minio.error import S3Error\n",
"\n",
"\n",
"def main():\n",
"\n",
" client = Minio(\n",
" \"minio_endpoint\",\n",
" access_key=\"key\",\n",
" secret_key=\"secret\",\n",
" )\n",
"\n",
" # Make 'asiatrip' bucket if not exist.\n",
" found = client.bucket_exists(\"bucket\")\n",
" if not found:\n",
" client.make_bucket(\"bucket\")\n",
" else:\n",
" print(\"Bucket already exists\")\n",
"\n",
" client.fput_object(\n",
" \"bucket\", \"bucket_file\", \"local_file_path\",\n",
" )\n",
" print(\n",
" \"'local_file_path' is successfully uploaded as \"\n",
" \"object 'bucket_file' to bucket 'bucket'.\"\n",
" )\n",
"\n",
"\n",
"if __name__ == \"__main__\":\n",
" try:\n",
" main()\n",
" except S3Error as exc:\n",
" print(\"error occurred.\", exc)"
]
}
],
"metadata": {
"language_info": {
"name": "python"
},
"orig_nbformat": 4
},
"nbformat": 4,
"nbformat_minor": 2
}