Skip to content

Instantly share code, notes, and snippets.

@lusoal
Created October 29, 2020 12:51
Show Gist options
  • Select an option

  • Save lusoal/e41b8fcab5ac017433b5218aebca573e to your computer and use it in GitHub Desktop.

Select an option

Save lusoal/e41b8fcab5ac017433b5218aebca573e to your computer and use it in GitHub Desktop.
dataset_car_path_ec2 = "/home/ec2-user/SageMaker/sagemaker-advanced-workshop/labs/01-sagemaker-introduction/datasetcars"
dataset_car_path_s3 = f"{prefix}/datasetcars"
def upload_to_s3_new(channel, file, file_name):
s3 = boto3.resource('s3')
data = open(file, 'rb')
key = f'{channel}/{file_name}'
s3.Bucket(bucket).put_object(Key=key, Body=data)
images = os.listdir(dataset_car_path_ec2)
for image in images:
print(f"Uploading {image} to {bucket}")
upload_to_s3_new(dataset_car_path_s3, f"{dataset_car_path_ec2}/{image}", image)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment