How to Process file on S3 event through AWS lambda using C#

扶醉桌前 提交于 2021-02-11 15:29:49

问题


I am looking for C# code blocks to read file from S3 on PUT event and upload the file to another bucket. I am fairly new to C# and see most of the blogs are either written for python and java. Any help will be highly appreciated.

Thanks,


回答1:


The flow would be:

  • Configure an Amazon S3 Event to trigger the AWS Lambda function when a new object is created
  • Details of the object created will be passed to the Lambda function via the event
  • Your Lambda function should then call CopyObject() to duplicate the object to another bucket (no need to download/upload)

See also: Copying Objects - Amazon Simple Storage Service




回答2:


Create a bucket and create IAM role that has access to the bucket you created. Assign to that role to your lambda function ( either thru AWS console or AWS SDK if you use Visual studio. the option is available in the following screenshot1)

After you published go to the Event Trigger tab and add the bucket you created. Make sure you upload the code again once you set this trigger

Upload a file and check from the cloud watch log to see function has executed. Some sample code is attached here



来源:https://stackoverflow.com/questions/59580592/how-to-process-file-on-s3-event-through-aws-lambda-using-c-sharp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!