Why are no Amazon S3 authentication handlers ready?

后端 未结 12 2155
广开言路
广开言路 2020-12-13 08:21

I have my $AWS_ACCESS_KEY_ID and $AWS_SECRET_ACCESS_KEY environment variables set properly, and I run this code:

import boto
conn = boto.connect_s3()
         


        
12条回答
  •  我在风中等你
    2020-12-13 09:24

    Boto will take your credentials from the environment variables. I've tested this with V2.0b3 and it works fine. It will give precedence to credentials specified explicitly in the constructor, but it will pick up credentials from the environment variables too.

    The simplest way to do this is to put your credentials into a text file, and specify the location of that file in the environment.

    For example (on Windows: I expect it will work just the same on Linux but I have not personally tried that)

    Create a file called "mycred.txt" and put it into C:\temp This file contains two lines:

    AWSAccessKeyId=
    AWSSecretKey=
    

    Define the environment variable AWS_CREDENTIAL_FILE to point at C:\temp\mycred.txt

    C:\>SET AWS_CREDENTIAL_FILE=C:\temp\mycred.txt
    

    Now your code fragment above:

    import boto
    conn = boto.connect_s3()
    

    will work fine.

提交回复
热议问题