File tree Expand file tree Collapse file tree 3 files changed +15
-10
lines changed
Expand file tree Collapse file tree 3 files changed +15
-10
lines changed Original file line number Diff line number Diff line change @@ -51,7 +51,7 @@ if [ "$os" == "Darwin" ]; then
5151 (
5252 cd lambdas/resize
5353 rm -rf libs lambda.zip
54- docker run --platform linux/x86_64 -v " $PWD " :/var/task " public.ecr.aws/sam/build-python3.9" /bin/sh -c " pip install -r requirements.txt -t libs; exit"
54+ docker run --platform linux/x86_64 --rm - v " $PWD " :/var/task " public.ecr.aws/sam/build-python3.9" /bin/sh -c " pip install -r requirements.txt -t libs; exit"
5555 cd libs && zip -r ../lambda.zip . && cd ..
5656 zip lambda.zip handler.py
5757 rm -rf libs
Original file line number Diff line number Diff line change @@ -31,7 +31,10 @@ def handler(event, context):
3131 raise ValueError ("no key given" )
3232
3333 # make sure the bucket exists
34- s3 .create_bucket (Bucket = bucket )
34+ try :
35+ s3 .head_bucket (Bucket = bucket )
36+ except Exception :
37+ s3 .create_bucket (Bucket = bucket )
3538
3639 # make sure the object does not exist
3740 try :
Original file line number Diff line number Diff line change 7878 let urlToCall = functionUrlPresign + "/" + fileName
7979 console . log ( urlToCall ) ;
8080
81- let form = this ;
82-
8381 $ . ajax ( {
8482 url : urlToCall ,
8583 success : function ( data ) {
8684 console . log ( "got pre-signed POST URL" , data ) ;
8785
88- // set form fields to make it easier to serialize
8986 let fields = data [ 'fields' ] ;
90- $ ( form ) . attr ( "action" , data [ 'url' ] ) ;
91- for ( let key in fields ) {
92- $ ( "#" + key ) . val ( fields [ key ] ) ;
93- }
9487
95- let formData = new FormData ( $ ( "#uploadForm" ) [ 0 ] ) ;
88+ let formData = new FormData ( )
89+
90+ Object . entries ( fields ) . forEach ( ( [ field , value ] ) => {
91+ formData . append ( field , value ) ;
92+ } ) ;
93+
94+ // the file <input> element, "file" needs to be the last element of the form
95+ const fileElement = document . querySelector ( "#customFile" ) ;
96+ formData . append ( "file" , fileElement . files [ 0 ] ) ;
97+
9698 console . log ( "sending form data" , formData ) ;
9799
98100 $ . ajax ( {
You can’t perform that action at this time.
0 commit comments