Skip to content

Instantly share code, notes, and snippets.

@tati
Last active February 25, 2018 03:10
Show Gist options
  • Select an option

  • Save tati/73104791bafb58befa092867b6d579e5 to your computer and use it in GitHub Desktop.

Select an option

Save tati/73104791bafb58befa092867b6d579e5 to your computer and use it in GitHub Desktop.

Revisions

  1. tati revised this gist Oct 15, 2017. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion boto3_DO-spaces.py
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,3 @@
    import boto3
    from boto3 import session
    from botocore.client import Config

  2. tati revised this gist Oct 15, 2017. 1 changed file with 17 additions and 4 deletions.
    21 changes: 17 additions & 4 deletions boto3_DO-spaces.py
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,17 @@
    # List all buckets on your account.
    response = client.list_buckets()
    spaces = [space[‘Name’] for space in response[‘Buckets’]]
    print(“Spaces List: %s% spaces)
    import boto3
    from boto3 import session
    from botocore.client import Config

    ACCESS_ID = 'XXXXXXX'
    SECRET_KEY = 'XXXXXXX'

    # Initiate session
    session = session.Session()
    client = session.client('s3',
    region_name='nyc3',
    endpoint_url='https://nyc3.digitaloceanspaces.com',
    aws_access_key_id=ACCESS_ID,
    aws_secret_access_key=SECRET_KEY)

    # Upload a file to your Space
    client.upload_file('test.html', 'hello-spaces', 'new-folder/new_file_name.html')
  3. tati revised this gist Oct 15, 2017. 1 changed file with 4 additions and 17 deletions.
    21 changes: 4 additions & 17 deletions boto3_DO-spaces.py
    Original file line number Diff line number Diff line change
    @@ -1,17 +1,4 @@
    import boto3
    from boto3 import session
    from botocore.client import Config

    ACCESS_ID = 'XXXXXXX'
    SECRET_KEY = 'XXXXXXX'

    # Initiate session
    session = session.Session()
    client = session.client('s3',
    region_name='nyc3',
    endpoint_url='https://nyc3.digitaloceanspaces.com',
    aws_access_key_id=ACCESS_ID,
    aws_secret_access_key=SECRET_KEY)

    NEW_BUCKET_NAME = 'hello-spaces'
    client.create_bucket(Bucket=NEW_BUCKET_NAME )
    # List all buckets on your account.
    response = client.list_buckets()
    spaces = [space[‘Name’] for space in response[‘Buckets’]]
    print(“Spaces List: %s% spaces)
  4. tati revised this gist Oct 15, 2017. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions boto3_DO-spaces.py
    Original file line number Diff line number Diff line change
    @@ -12,3 +12,6 @@
    endpoint_url='https://nyc3.digitaloceanspaces.com',
    aws_access_key_id=ACCESS_ID,
    aws_secret_access_key=SECRET_KEY)

    NEW_BUCKET_NAME = 'hello-spaces'
    client.create_bucket(Bucket=NEW_BUCKET_NAME )
  5. tati revised this gist Oct 15, 2017. 1 changed file with 4 additions and 1 deletion.
    5 changes: 4 additions & 1 deletion boto3_DO-spaces.py
    Original file line number Diff line number Diff line change
    @@ -2,10 +2,13 @@
    from boto3 import session
    from botocore.client import Config

    ACCESS_ID = 'XXXXXXX'
    SECRET_KEY = 'XXXXXXX'

    # Initiate session
    session = session.Session()
    client = session.client('s3',
    region_name='nyc3',
    endpoint_url='https://nyc3.digitaloceanspaces.com',
    aws_access_key_id=ACCESS_ID,
    aws_secret_access_key=SECRET_KEY)
    aws_secret_access_key=SECRET_KEY)
  6. tati revised this gist Oct 15, 2017. 1 changed file with 9 additions and 5 deletions.
    14 changes: 9 additions & 5 deletions boto3_DO-spaces.py
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,11 @@
    import boto3
    from boto3 import session
    from botocore.client import Config

    # Initiate session
    session = session.Session()
    client = session.client(s3,
    region_name=nyc3',
    endpoint_url=https://nyc3.digitaloceanspaces.com',
    aws_access_key_id=<INSERT ACCESS_ID>,
    aws_secret_access_key=<INSERT SECRET_KEY>)
    client = session.client('s3',
    region_name='nyc3',
    endpoint_url='https://nyc3.digitaloceanspaces.com',
    aws_access_key_id=ACCESS_ID,
    aws_secret_access_key=SECRET_KEY)
  7. tati created this gist Oct 15, 2017.
    7 changes: 7 additions & 0 deletions boto3_DO-spaces.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    # Initiate session
    session = session.Session()
    client = session.client(‘s3’,
    region_name=nyc3',
    endpoint_url=https://nyc3.digitaloceanspaces.com',
    aws_access_key_id=<INSERT ACCESS_ID>,
    aws_secret_access_key=<INSERT SECRET_KEY>)