问题
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