AWS lambda函数:在php中直接浏览器上传时不会触发put事件
I've successfully created a lambda function that resizes an image and stores into a bucket in s3(bucket name:cropped
).
Also this lambda function invokes when a file is uploaded into another bucket(bucket name:source
).
When i upload an image through aws console into the source
bucket the AWS lambda function is triggered and the cropped image is created in cropped
bucket.
But when i try with programmatic file upload ( s3 browser file upload) the lambda function is not triggered(cropped image is not creating in cropped
bucket) however the image is successfully uploaded into source
bucket.
Browser file upload
<form id="upload" action="//s3-us-west-2.amazonaws.com/lambdacushbu" method="POST" enctype="multipart/form-data">
<input type="hidden" name="Content-Type" value="multipart/form-data" />
<input type="hidden" name="acl" value="private" />
<input type="hidden" name="success_action_status" value="201" />
<input type="hidden" name="policy" value="eyJleHBpcmF0aW9uIjoiMjAxNy0wMy0yNFQxMTo0NDoxMFoiLCJjb25kaXRpb25zIjpbeyJidWNrZXQiOiJsYW1iZGFjdXNoYnUifSx7ImFjbCI6InByaXZhdGUifSxbInN0YXJ0cy13aXRoIiwiJGtleSIsIiJdLFsiZXEiLCIkQ29udGVudC1UeXBlIiwibXVsdGlwYXJ0XC9mb3JtLWRhdGEiXSxbImNvbnRlbnQtbGVuZ3RoLXJhbmdlIiwwLDUyNDI4ODAwMF0seyJzdWNjZXNzX2FjdGlvbl9zdGF0dXMiOiIyMDEifSx7IngtYW16LWNyZWRlbnRpYWwiOiJBS0lBSlJWRVhVVFRWTjROWUFSUVwvMjAxNzAzMjRcL3VzLXdlc3QtMlwvczNcL2F3czRfcmVxdWVzdCJ9LHsieC1hbXotYWxnb3JpdGhtIjoiQVdTNC1ITUFDLVNIQTI1NiJ9LHsieC1hbXotZGF0ZSI6IjIwMTcwMzI0VDA1NDQxMFoifV19" />
<input type="hidden" name="X-amz-credential" value="AKIAJRVEARQ/20170324/us-west-2/s3/aws4_request" />
<input type="hidden" name="X-amz-algorithm" value="AWS4-HMAC-SHA256" />
<input type="hidden" name="X-amz-date" value="20170324T054410Z" />
<input type="hidden" name="X-amz-signature" value="854ea7ec0c456c03509d22a6de39b045e54b71a779af8d88175717d8b54ccebc" />
<input type="hidden" name="key" value="${filename}" />
<input type="file" name="file" id="image">
<br>
<input type="submit" value="upload" name="upload">
<span id="status-text"></span>
<img src="" id="cropped-image">
</form>
UPDATE
I've tried with normal file upload method ie user uploads file to my server and then it put into aws s3 bucket. Now its working
So i think there is an issue with direct browser upload
我已成功创建了一个lambda函数,该函数调整图像大小并存储到s3中的存储桶中(存储桶名称:裁剪 code>)。
此外,当文件上传到另一个存储桶(存储桶名称: 当我 通过aws控制台将图像上传到 但是当我尝试使用程序化文件上传(s3浏览器文件上传)时,不会触发lambda函数(裁剪后的图像不会在 浏览器文件上传 strong> p>
UPDATE strong> p>
我尝试过普通的文件上传方法,即用户将文件上传到我的服务器,然后将其放入aws s3存储桶。
Now 它的工作 p>
所以我认为直接浏览器上传存在问题 p>
div> source code>)时,此lambda函数会调用。 p>
source code>存储桶中,触发AWS lambda函数,并在
cropped code>存储桶中创建裁剪后的图像。 p>
cropped code>存储桶中创建)但是图像已成功上传到
source bucket。 p>
&lt; form id =“upload”action = “//s3-us-west-2.amazonaws.com/lambdacushbu”method =“POST”enctype =“multipart / form-data”&gt;
&lt; input type =“hidden”name =“Content-” 输入“value =”multipart / form- data“/&gt;
&lt; input type =”hidden“name =”acl“value =”private“/&gt;
&lt; input type =”hidden“name =”success_action_status“value =”201“/&gt; \ n&lt; input type =“hidden”name =“policy”value =“”/&gt;
&lt; input type =“hidden”name =“X-amz-credential”value =“AKIAJRVEARQ / 20170324 / us-west-2 / s3 / aws4_request“/&gt;
&lt; input type =”hidden“name =”X-amz-algorithm“value =”AWS4-HMAC-SHA256“/&gt;
&lt; input type =”hidden“name =” X-amz-date“value =”20170324T054410Z“/&gt;
&lt; input type =” 隐藏“name =”X-amz-signature“value =”854ea7ec0c456c03509d22a6de39b045e54b71a779af8d88175717d8b54ccebc“/&gt;
&lt; input type =”hidden“name =”key“value =”$ {filename}“/&gt;
&lt;输入类型 =“file”name =“file”id =“image”&gt;
&lt; br&gt;
&lt; input type =“submit”value =“upload”name =“upload”&gt;
&lt; span id =“status-text”&gt;&lt; / span&gt;
&lt; img src =“”id =“cropped-image”&gt;
&lt; / form&gt;
code> pre>
\ n
Finally i resolved the issue for the browser direct uploads the events is POST
For enabling
1.Go to s3 console and select the bucket.
2.Go to properties select Events and add a new event with POST
Create the event with post and choose your lambda function that you want to invoke and save.