Created
October 8, 2018 20:20
-
-
Save ericsalesdeandrade-zz/fc57f6dfcbb3cc8054ccc52f3a6387f5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import boto3 | |
def get_car(event, context): | |
try: | |
s3 = boto3.resource('s3') | |
client_s3 = boto3.client('s3') | |
brand_upper = event["brand"].upper() | |
bucket = s3.Bucket("car-images-hd") | |
for obj in bucket.objects.filter(Prefix=brand_upper + '/'): | |
url = "https://s3-eu-west-1.amazonaws.com/" + obj.bucket_name + "/" + obj.key | |
return ("Image URL is {0}".format(url)) | |
return("*** Failure to retrieve Car Image - Please check your request ***") | |
except BaseException as error: | |
print("*** Failure to retrieve Car Image - Please check your request ***") | |
return str(error) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment