Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug in example code sample #806

Closed
urandu opened this issue Oct 12, 2019 · 0 comments
Closed

Bug in example code sample #806

urandu opened this issue Oct 12, 2019 · 0 comments

Comments

@urandu
Copy link
Contributor

urandu commented Oct 12, 2019

I am not sure if it is by design, but I strongly feel that the example code given for uploading a file in the README is misguiding https://github.com/minio/minio-py#file-uploaderpy . This is because, according to this snippet, the file shall be uploaded only if the bucket does not exist, otherwise, if it exists, the code in the else block will never be executed.

from minio import Minio
from minio.error import (ResponseError, BucketAlreadyOwnedByYou,
                         BucketAlreadyExists)

# Initialize minioClient with an endpoint and access/secret keys.
minioClient = Minio('play.min.io',
                    access_key='Q3AM3UQ867SPQQA43P2F',
                    secret_key='zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG',
                    secure=True)

# Make a bucket with the make_bucket API call.
try:
       minioClient.make_bucket("maylogs", location="us-east-1")
except BucketAlreadyOwnedByYou as err:
       pass
except BucketAlreadyExists as err:
       pass
except ResponseError as err:
       raise
else:
        # Put an object 'pumaserver_debug.log' with contents from 'pumaserver_debug.log'.
        try:
               minioClient.fput_object('maylogs', 'pumaserver_debug.log', '/tmp/pumaserver_debug.log')
        except ResponseError as err:
               print(err)

I can take this up and make the change.

urandu added a commit to urandu/minio-py that referenced this issue Oct 12, 2019
This PR addressed this issue minio#806
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant