|
| 1 | +{ |
| 2 | + "cells": [ |
| 3 | + { |
| 4 | + "cell_type": "code", |
| 5 | + "id": "initial_id", |
| 6 | + "metadata": { |
| 7 | + "collapsed": true, |
| 8 | + "ExecuteTime": { |
| 9 | + "end_time": "2025-02-28T23:38:56.420160Z", |
| 10 | + "start_time": "2025-02-28T23:38:55.221431Z" |
| 11 | + } |
| 12 | + }, |
| 13 | + "source": "!pip install boto3", |
| 14 | + "outputs": [ |
| 15 | + { |
| 16 | + "name": "stdout", |
| 17 | + "output_type": "stream", |
| 18 | + "text": [ |
| 19 | + "\u001B[33mDEPRECATION: Loading egg at /opt/homebrew/lib/python3.11/site-packages/BlinkStick-1.2.0-py3.11.egg is deprecated. pip 24.3 will enforce this behaviour change. A possible replacement is to use pip for package installation.. Discussion can be found at https://github.com/pypa/pip/issues/12330\u001B[0m\u001B[33m\r\n", |
| 20 | + "\u001B[0m\u001B[33mDEPRECATION: Loading egg at /opt/homebrew/lib/python3.11/site-packages/pyusb-1.2.1-py3.11.egg is deprecated. pip 24.3 will enforce this behaviour change. A possible replacement is to use pip for package installation.. Discussion can be found at https://github.com/pypa/pip/issues/12330\u001B[0m\u001B[33m\r\n", |
| 21 | + "\u001B[0mRequirement already satisfied: boto3 in /opt/homebrew/lib/python3.11/site-packages (1.37.4)\r\n", |
| 22 | + "Requirement already satisfied: botocore<1.38.0,>=1.37.4 in /opt/homebrew/lib/python3.11/site-packages (from boto3) (1.37.4)\r\n", |
| 23 | + "Requirement already satisfied: jmespath<2.0.0,>=0.7.1 in /opt/homebrew/lib/python3.11/site-packages (from boto3) (1.0.1)\r\n", |
| 24 | + "Requirement already satisfied: s3transfer<0.12.0,>=0.11.0 in /opt/homebrew/lib/python3.11/site-packages (from boto3) (0.11.3)\r\n", |
| 25 | + "Requirement already satisfied: python-dateutil<3.0.0,>=2.1 in /Users/artium/Library/Python/3.11/lib/python/site-packages (from botocore<1.38.0,>=1.37.4->boto3) (2.8.2)\r\n", |
| 26 | + "Requirement already satisfied: urllib3!=2.2.0,<3,>=1.25.4 in /opt/homebrew/lib/python3.11/site-packages (from botocore<1.38.0,>=1.37.4->boto3) (1.26.15)\r\n", |
| 27 | + "Requirement already satisfied: six>=1.5 in /opt/homebrew/lib/python3.11/site-packages (from python-dateutil<3.0.0,>=2.1->botocore<1.38.0,>=1.37.4->boto3) (1.17.0)\r\n", |
| 28 | + "\r\n", |
| 29 | + "\u001B[1m[\u001B[0m\u001B[34;49mnotice\u001B[0m\u001B[1;39;49m]\u001B[0m\u001B[39;49m A new release of pip is available: \u001B[0m\u001B[31;49m24.0\u001B[0m\u001B[39;49m -> \u001B[0m\u001B[32;49m25.0.1\u001B[0m\r\n", |
| 30 | + "\u001B[1m[\u001B[0m\u001B[34;49mnotice\u001B[0m\u001B[1;39;49m]\u001B[0m\u001B[39;49m To update, run: \u001B[0m\u001B[32;49mpython3.11 -m pip install --upgrade pip\u001B[0m\r\n" |
| 31 | + ] |
| 32 | + } |
| 33 | + ], |
| 34 | + "execution_count": 3 |
| 35 | + }, |
| 36 | + { |
| 37 | + "metadata": { |
| 38 | + "ExecuteTime": { |
| 39 | + "end_time": "2025-02-28T23:38:56.444149Z", |
| 40 | + "start_time": "2025-02-28T23:38:56.426837Z" |
| 41 | + } |
| 42 | + }, |
| 43 | + "cell_type": "code", |
| 44 | + "source": [ |
| 45 | + "import boto3\n", |
| 46 | + "from botocore.client import Config\n", |
| 47 | + "\n", |
| 48 | + "# MinIO server information\n", |
| 49 | + "minio_endpoint = 'http://localhost:9000' # Update with your MinIO server URL\n", |
| 50 | + "access_key = 'minioadmin' # Replace with your MinIO access key\n", |
| 51 | + "secret_key = 'minioadmin' # Replace with your MinIO secret key\n", |
| 52 | + "bucket_name = 'your-bucket-name' # Replace with your bucket name\n", |
| 53 | + "\n", |
| 54 | + "# Create a session and S3 client\n", |
| 55 | + "session = boto3.session.Session()\n", |
| 56 | + "s3_client = session.client(\n", |
| 57 | + " 's3',\n", |
| 58 | + " endpoint_url=minio_endpoint,\n", |
| 59 | + " aws_access_key_id=access_key,\n", |
| 60 | + " aws_secret_access_key=secret_key,\n", |
| 61 | + " config=Config(signature_version='s3v4'),\n", |
| 62 | + " region_name='us-east-1' # Adjust if necessary\n", |
| 63 | + ")\n", |
| 64 | + "\n", |
| 65 | + "# List objects in the specified bucket\n", |
| 66 | + "response = s3_client.list_objects_v2(Bucket=bucket_name)\n", |
| 67 | + "\n", |
| 68 | + "if 'Contents' in response:\n", |
| 69 | + " for obj in response['Contents']:\n", |
| 70 | + " print(f\"Object: {obj['Key']} (Size: {obj['Size']} bytes)\")\n", |
| 71 | + "else:\n", |
| 72 | + " print(f\"No objects found in bucket '{bucket_name}'.\")" |
| 73 | + ], |
| 74 | + "id": "708f9b0198a5c3f0", |
| 75 | + "outputs": [ |
| 76 | + { |
| 77 | + "ename": "ModuleNotFoundError", |
| 78 | + "evalue": "No module named 'boto3'", |
| 79 | + "output_type": "error", |
| 80 | + "traceback": [ |
| 81 | + "\u001B[31m---------------------------------------------------------------------------\u001B[39m", |
| 82 | + "\u001B[31mModuleNotFoundError\u001B[39m Traceback (most recent call last)", |
| 83 | + "\u001B[36mCell\u001B[39m\u001B[36m \u001B[39m\u001B[32mIn[4]\u001B[39m\u001B[32m, line 1\u001B[39m\n\u001B[32m----> \u001B[39m\u001B[32m1\u001B[39m \u001B[38;5;28;01mimport\u001B[39;00m\u001B[38;5;250m \u001B[39m\u001B[34;01mboto3\u001B[39;00m\n\u001B[32m 2\u001B[39m \u001B[38;5;28;01mfrom\u001B[39;00m\u001B[38;5;250m \u001B[39m\u001B[34;01mbotocore\u001B[39;00m\u001B[34;01m.\u001B[39;00m\u001B[34;01mclient\u001B[39;00m\u001B[38;5;250m \u001B[39m\u001B[38;5;28;01mimport\u001B[39;00m Config\n\u001B[32m 4\u001B[39m \u001B[38;5;66;03m# MinIO server information\u001B[39;00m\n", |
| 84 | + "\u001B[31mModuleNotFoundError\u001B[39m: No module named 'boto3'" |
| 85 | + ] |
| 86 | + } |
| 87 | + ], |
| 88 | + "execution_count": 4 |
| 89 | + } |
| 90 | + ], |
| 91 | + "metadata": { |
| 92 | + "kernelspec": { |
| 93 | + "display_name": "Python 3", |
| 94 | + "language": "python", |
| 95 | + "name": "python3" |
| 96 | + }, |
| 97 | + "language_info": { |
| 98 | + "codemirror_mode": { |
| 99 | + "name": "ipython", |
| 100 | + "version": 2 |
| 101 | + }, |
| 102 | + "file_extension": ".py", |
| 103 | + "mimetype": "text/x-python", |
| 104 | + "name": "python", |
| 105 | + "nbconvert_exporter": "python", |
| 106 | + "pygments_lexer": "ipython2", |
| 107 | + "version": "2.7.6" |
| 108 | + } |
| 109 | + }, |
| 110 | + "nbformat": 4, |
| 111 | + "nbformat_minor": 5 |
| 112 | +} |
0 commit comments