Skip to content
Snippets Groups Projects
Commit 4938c663 authored by Alexander Drummer's avatar Alexander Drummer
Browse files

updated README.md; less verbose logging

parent 6a5bd853
Branches
No related tags found
No related merge requests found
......@@ -13,7 +13,7 @@ docker build -t my-minio-uploader .
- Run the image
```bash
docker run -e MINIO_ENDPOINT=your-minio-endpoint -e MINIO_ACCESS_KEY=your-access-key -e MINIO_SECRET_KEY=your-secret-key -e MINIO_BUCKET_NAME=your-bucket-name -e LOCAL_DIRECTORY='/path/to/local/directory' -e SECURE_OPTION=true -e VALID_EXTENSIONS='.jpg,.png,.jpeg' my-minio-uploader
docker run -e MINIO_ENDPOINT=your-minio-endpoint -e MINIO_ACCESS_KEY=your-access-key -e MINIO_SECRET_KEY=your-secret-key -e MINIO_BUCKET_NAME=your-bucket-name -e SECURE_OPTION='true' -e VALID_EXTENSIONS='.jpg,.png,.jpeg' -e LOG_ENABLED='true' -v $(pwd)/images:/app/images my-minio-uploader
```
Environment variables:
- MINIO_ENDPOINT
......@@ -21,15 +21,16 @@ Environment variables:
- MINIO_SECRET_KEY
- MINIO_BUCKET_NAME
- SECURE_OPTION
- LOCAL_DIRECTORY
- FILE_EXTENSION
- LOG_ENABLED
The VALID_EXTENSIONS environment variable is expected to be a comma-separated list of valid file extensions (e.g., .jpg,.png).
Important: Mount your local host machines image directory as volume in the container as /app/images.
The VALID_EXTENSIONS environment variable is expected to be a comma-separated list of valid file extensions (e.g., .jpg,.png,.jp2).
SECURE_OPTION environment variable is used to set the secure option for the MinIO client. It defaults to False if not specified or if set to any value other than the string 'true'. Adjust the environment variables accordingly when running the script.
LOG_ENABLED environment variable is used to control whether logging is enabled. If LOG_ENABLED is set to 'true', logging is set to INFO; otherwise, it is set to ERROR. Adjust the environment variable according to your needs when running the script.
Make sure your script (uploader.py) and the requirements.txt is in the same directory as the Dockerfile.
......@@ -10,13 +10,10 @@ def upload_images_recursive(minio_client, bucket_name, local_directory, valid_ex
logging.info(f"Scanning directory: {local_directory}")
for root, dirs, files in os.walk(local_directory):
logging.info(f"Files: {files}")
for file in files:
file_path = os.path.join(root, file)
print(file_path)
logging.info(f"Filepath: {file_path}")
object_name = os.path.relpath(file_path, local_directory)
logging.info(f"Processing file: {file_path}")
if any(file.lower().endswith(ext.lower()) for ext in valid_extensions):
......@@ -33,7 +30,6 @@ def upload_images_recursive(minio_client, bucket_name, local_directory, valid_ex
all_files = [os.path.join(root, file) for root, _, files in os.walk(local_directory) for file in files]
logging.info(f"All files in directory: {all_files}")
# ... (previous code)
if __name__ == "__main__":
# MinIO server information
......@@ -61,9 +57,6 @@ if __name__ == "__main__":
upload_images_recursive(minio_client, minio_bucket_name, local_directory, valid_extensions)
#########
# List objects in the bucket to verify the upload
try:
objects = list(minio_client.list_objects(minio_bucket_name))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment