Skip to content

Commit

Permalink
Pushing lab4
Browse files Browse the repository at this point in the history
  • Loading branch information
Ziya Jasani authored and Ziya Jasani committed Oct 3, 2024
1 parent 344ecf2 commit b5981a3
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 0 deletions.
Binary file added my-work/lab4/flowers.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions my-work/lab4/lab4_python_script.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
bucket = 'ds2022-mst3k'
local_file = 'project/vuelta.jpg'

resp = s3.put_object(
Body = local_file,
Bucket = bucket,
Key = local_file
)
35 changes: 35 additions & 0 deletions my-work/lab4/lab4_second_script.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/python3

import urllib.request
import boto3

url = 'https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png'

bucket = 'ds2022-eme4de'
expires_in = 604800

urllib.request.urlretrieve(url, 'flowers.jpg')

local_file = 'flowers.jpg'
object_name = 'flowers.jpg'

s3 = boto3.client('s3', region_name="us-east-1")

resp = s3.put_object(
Body = local_file,
Bucket = bucket,
Key = local_file,
ACL = 'public-read'
)

s3.upload_file(local_file, bucket, object_name)

response = s3.generate_presigned_url(
'get_object',
Params={'Bucket': bucket, 'Key': object_name},
ExpiresIn=expires_in
)

print(response)

#https://ds2022-eme4de.s3.amazonaws.com/flowers.jpg?AWSAccessKeyId=AKIAUPMYNIILKRYU3I6O&Signature=6mYO61IiQLzGFokAUSW0SyyJt4c%3D&Expires=1728595188

0 comments on commit b5981a3

Please sign in to comment.