Search This Blog

Showing posts with label bucket. Show all posts
Showing posts with label bucket. Show all posts

Tuesday, April 14, 2020

Python AWS S3 - Upload a File

import os
import boto3
from botocore.exceptions import NoCredentialsError

ACCESS_KEY = 'AK....'
AWS_ACCESS_SECRET_KEY = 'DZKtksHidEexxxxxxx'

def upload_to_aws(local_file, bucket, s3_file):
    s3 = boto3.client('s3', aws_access_key_id=ACCESS_KEY,
                      aws_secret_access_key=AWS_ACCESS_SECRET_KEY)

    try:
        s3.upload_file(local_file, bucket, s3_file)
        print("Upload Successful")
        return True
    except FileNotFoundError:
        print("The file was not found")
        return False
    except NoCredentialsError:
        print("Credentials not available")
        return False



file = open('test.png', 'r+')

key = file.name
bucket = 'dev-nw'

uploaded = upload_to_aws('test.png', bucket, key)
    


#download a file
s3 = boto3.client( 's3', aws_access_key_id=ACCESS_KEY, aws_secret_access_key=AWS_ACCESS_SECRET_KEY );   
s3.download_file( bucket, key, 'D:/airtel-download.png' );



Wednesday, February 10, 2016

Git or bitbucket checkout public key - Self signed certificate issue

git-Checkout
************


1. generate your self signed private key from "putty-gen.exe" or "open ssl" etc..
    > generate new key
    > save private key ex: D:/drvijay/self-private.ppk


2. type  the below command in cmd 1. to ignore ssl verify, 2. add your self certificate , 


3. check out 

    > git config --global http.sslverify false
    > git config --system http.sslCAPath D:/drvijay/self-private.ppk

    > git clone https://@url/repo.git
    > pwd: test123


-- Enjoy

Hit Counter


View My Stats