update: put -> post
This commit is contained in:
parent
c37017d291
commit
ab8fcfd665
@ -15,7 +15,7 @@ def lambda_handler(event, _context):
|
||||
filename = event['filename']
|
||||
|
||||
try:
|
||||
url = s3.generate_presigned_put(BUCKET, filename)
|
||||
url = s3.generate_presigned_post(BUCKET, filename)
|
||||
print("Got presigned URL: %s", url)
|
||||
except ClientError as e:
|
||||
print(e)
|
||||
|
@ -11,20 +11,20 @@ import requests
|
||||
from awscrt import mqtt
|
||||
from awsiot import mqtt_connection_builder
|
||||
|
||||
DEBUG = 0
|
||||
DEBUG = 1
|
||||
|
||||
UUID = f"cloudprog-{uuid.uuid4()}"
|
||||
|
||||
ENDPOINT = ""
|
||||
CA = ""
|
||||
CERT = ""
|
||||
PRIVKEY = ""
|
||||
ENDPOINT = "a1io7cze9x1oli-ats.iot.us-east-1.amazonaws.com"
|
||||
CA = "rootCA.pem"
|
||||
CERT = "cert.crt"
|
||||
PRIVKEY = "privkey.pem"
|
||||
|
||||
LED_TOPIC = ""
|
||||
LED_TOPIC = "cloudprog/hw4/team02/led"
|
||||
|
||||
# https://aws.amazon.com/tw/blogs/iot/securely-ingesting-large-sized-payloads-from-iot-devices-to-the-aws-cloud/
|
||||
S3_UPLOAD_TOPIC = ""
|
||||
S3_URL_TOPIC = ""
|
||||
S3_UPLOAD_TOPIC = "cloudprog/hw4/team02/s3/upload"
|
||||
S3_URL_TOPIC = "cloudprog/hw4/team02/s3/url"
|
||||
|
||||
FORMAT = "jpg"
|
||||
|
||||
@ -95,7 +95,7 @@ def led_control(light):
|
||||
def parse_s3_url_payload(payload):
|
||||
data = json.loads(payload.decode())
|
||||
|
||||
put_presigned_s3_url(data["url"], take_picture())
|
||||
post_presigned_s3_url(data["url"], take_picture())
|
||||
|
||||
|
||||
def take_picture():
|
||||
@ -106,8 +106,8 @@ def take_picture():
|
||||
return img.tobytes()
|
||||
|
||||
|
||||
def put_presigned_s3_url(url, img_bytes):
|
||||
res = requests.put(url, data=img_bytes)
|
||||
def post_presigned_s3_url(url, img_bytes):
|
||||
res = requests.post(url, data=img_bytes)
|
||||
print(f"Put to S3. status code: {res.status_code}")
|
||||
return res
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user