Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public async Task<string> FunctionHandler(S3Event evnt, ILambdaContext context)
- {
- var s3Event = evnt.Records?[0].S3;
- if(s3Event == null)
- {
- return null;
- }
- try
- {
- if(s3Event.Object.Key.ToLower().Contains("thumb"))
- {
- Console.WriteLine("The image is already a thumb file");
- return "";
- }
- var response = await this.S3Client.GetObjectMetadataAsync(s3Event.Bucket.Name, s3Event.Object.Key);
- return response.Headers.ContentType;
- }
- catch(Exception e)
- {
- context.Logger.LogLine($"Error getting object {s3Event.Object.Key} from bucket {s3Event.Bucket.Name}. Make sure they exist and your bucket is in the same region as this function.");
- context.Logger.LogLine(e.Message);
- context.Logger.LogLine(e.StackTrace);
- throw;
- }
- }
- {
- "errorType": "AggregateException",
- "errorMessage": "One or more errors occurred. (Error making request with Error Code MovedPermanently and Http Status Code MovedPermanently. No further error information was returned by the service.)",
- "stackTrace": [
- "at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)",
- "at lambda_method(Closure , Stream , Stream , LambdaContextInternal )"
- ],
- "cause": {
- "errorType": "AmazonS3Exception",
- "errorMessage": "Error making request with Error Code MovedPermanently and Http Status Code MovedPermanently. No further error information was returned by the service.",
- "stackTrace": [
- "at Amazon.Runtime.Internal.HttpErrorResponseExceptionHandler.HandleException(IExecutionContext executionContext, HttpErrorResponseException exception)",
- "at Amazon.Runtime.Internal.ErrorHandler.ProcessException(IExecutionContext executionContext, Exception exception)",
- "at Amazon.Runtime.Internal.ErrorHandler.<InvokeAsync>d__5`1.MoveNext()",
- "--- End of stack trace from previous location where exception was thrown ---",
- "at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()",
- "at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)",
- "at Amazon.Runtime.Internal.CallbackHandler.<InvokeAsync>d__9`1.MoveNext()",
- "--- End of stack trace from previous location where exception was thrown ---",
- "at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()",
- "at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)",
- "at Amazon.Runtime.Internal.CredentialsRetriever.<InvokeAsync>d__7`1.MoveNext()",
- "--- End of stack trace from previous location where exception was thrown ---",
- "at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()",
- "at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)",
- "at Amazon.Runtime.Internal.RetryHandler.<InvokeAsync>d__10`1.MoveNext()",
- "--- End of stack trace from previous location where exception was thrown ---",
- "at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()",
- "at Amazon.Runtime.Internal.RetryHandler.<InvokeAsync>d__10`1.MoveNext()",
- "--- End of stack trace from previous location where exception was thrown ---",
- "at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()",
- "at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)",
- "at Amazon.Runtime.Internal.CallbackHandler.<InvokeAsync>d__9`1.MoveNext()",
- "--- End of stack trace from previous location where exception was thrown ---",
- "at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()",
- "at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)",
- "at Amazon.Runtime.Internal.CallbackHandler.<InvokeAsync>d__9`1.MoveNext()",
- "--- End of stack trace from previous location where exception was thrown ---",
- "at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()",
- "at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)",
- "at Amazon.S3.Internal.AmazonS3ExceptionHandler.<InvokeAsync>d__1`1.MoveNext()",
- "--- End of stack trace from previous location where exception was thrown ---",
- "at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()",
- "at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)",
- "at Amazon.Runtime.Internal.ErrorCallbackHandler.<InvokeAsync>d__5`1.MoveNext()",
- "--- End of stack trace from previous location where exception was thrown ---",
- "at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()",
- "at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)",
- "at Amazon.Runtime.Internal.MetricsHandler.<InvokeAsync>d__1`1.MoveNext()",
- "--- End of stack trace from previous location where exception was thrown ---",
- "at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()",
- "at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)",
- "at AwsS3Lambda.Function.<FunctionHandler>d__6.MoveNext() in C:\Users\Acer\Desktop\MementoCSharp\memento-dotnet\AwsS3Lambda\Function.cs:line 73"
- ],
- "cause": {
- "errorType": "HttpErrorResponseException",
- "errorMessage": "Exception of type 'Amazon.Runtime.Internal.HttpErrorResponseException' was thrown.",
- "stackTrace": [
- "at Amazon.Runtime.Internal.RedirectHandler.HandleRedirect(IExecutionContext executionContext)",
- "at Amazon.Runtime.Internal.RedirectHandler.<InvokeAsync>d__1`1.MoveNext()",
- "--- End of stack trace from previous location where exception was thrown ---",
- "at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()",
- "at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)",
- "at Amazon.Runtime.Internal.Unmarshaller.<InvokeAsync>d__3`1.MoveNext()",
- "--- End of stack trace from previous location where exception was thrown ---",
- "at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()",
- "at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)",
- "at Amazon.S3.Internal.AmazonS3ResponseHandler.<InvokeAsync>d__1`1.MoveNext()",
- "--- End of stack trace from previous location where exception was thrown ---",
- "at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()",
- "at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)",
- "at Amazon.Runtime.Internal.ErrorHandler.<InvokeAsync>d__5`1.MoveNext()"
- ]
- }
- },
- "causes": [
- {
- "errorType": "AmazonS3Exception",
- "errorMessage": "Error making request with Error Code MovedPermanently and Http Status Code MovedPermanently. No further error information was returned by the service.",
- "stackTrace": [
- "at Amazon.Runtime.Internal.HttpErrorResponseExceptionHandler.HandleException(IExecutionContext executionContext, HttpErrorResponseException exception)",
- "at Amazon.Runtime.Internal.ErrorHandler.ProcessException(IExecutionContext executionContext, Exception exception)",
- "at Amazon.Runtime.Internal.ErrorHandler.<InvokeAsync>d__5`1.MoveNext()",
- "--- End of stack trace from previous location where exception was thrown ---",
- "at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()",
- "at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)",
- "at Amazon.Runtime.Internal.CallbackHandler.<InvokeAsync>d__9`1.MoveNext()",
- "--- End of stack trace from previous location where exception was thrown ---",
- "at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()",
- "at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)",
- "at Amazon.Runtime.Internal.CredentialsRetriever.<InvokeAsync>d__7`1.MoveNext()",
- "--- End of stack trace from previous location where exception was thrown ---",
- "at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()",
- "at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)",
- "at Amazon.Runtime.Internal.RetryHandler.<InvokeAsync>d__10`1.MoveNext()",
- "--- End of stack trace from previous location where exception was thrown ---",
- "at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()",
- "at Amazon.Runtime.Internal.RetryHandler.<InvokeAsync>d__10`1.MoveNext()",
- "--- End of stack trace from previous location where exception was thrown ---",
- "at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()",
- "at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)",
- "at Amazon.Runtime.Internal.CallbackHandler.<InvokeAsync>d__9`1.MoveNext()",
- "--- End of stack trace from previous location where exception was thrown ---",
- "at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()",
- "at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)",
- "at Amazon.Runtime.Internal.CallbackHandler.<InvokeAsync>d__9`1.MoveNext()",
- "--- End of stack trace from previous location where exception was thrown ---",
- "at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()",
- "at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)",
- "at Amazon.S3.Internal.AmazonS3ExceptionHandler.<InvokeAsync>d__1`1.MoveNext()",
- "--- End of stack trace from previous location where exception was thrown ---",
- "at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()",
- "at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)",
- "at Amazon.Runtime.Internal.ErrorCallbackHandler.<InvokeAsync>d__5`1.MoveNext()",
- "--- End of stack trace from previous location where exception was thrown ---",
- "at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()",
- "at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)",
- "at Amazon.Runtime.Internal.MetricsHandler.<InvokeAsync>d__1`1.MoveNext()",
- "--- End of stack trace from previous location where exception was thrown ---",
- "at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()",
- "at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)",
- "at AwsS3Lambda.Function.<FunctionHandler>d__6.MoveNext() in C:\Users\Acer\Desktop\MementoCSharp\memento-dotnet\AwsS3Lambda\Function.cs:line 73"
- ],
- "cause": {
- "errorType": "HttpErrorResponseException",
- "errorMessage": "Exception of type 'Amazon.Runtime.Internal.HttpErrorResponseException' was thrown.",
- "stackTrace": [
- "at Amazon.Runtime.Internal.RedirectHandler.HandleRedirect(IExecutionContext executionContext)",
- "at Amazon.Runtime.Internal.RedirectHandler.<InvokeAsync>d__1`1.MoveNext()",
- "--- End of stack trace from previous location where exception was thrown ---",
- "at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()",
- "at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)",
- "at Amazon.Runtime.Internal.Unmarshaller.<InvokeAsync>d__3`1.MoveNext()",
- "--- End of stack trace from previous location where exception was thrown ---",
- "at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()",
- "at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)",
- "at Amazon.S3.Internal.AmazonS3ResponseHandler.<InvokeAsync>d__1`1.MoveNext()",
- "--- End of stack trace from previous location where exception was thrown ---",
- "at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()",
- "at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)",
- "at Amazon.Runtime.Internal.ErrorHandler.<InvokeAsync>d__5`1.MoveNext()"
- ]
- }
- }
- ]
- }
Add Comment
Please, Sign In to add comment