/// <summary> /// This method is called for every Lambda invocation. This method takes in an S3 event object and can be used /// to respond to S3 notifications. /// </summary> /// <param name="evnt"></param> /// <param name="context"></param> /// <returns></returns> //public string FunctionHandler(string input, ILambdaContext context) //{ // //var keyName_new = "testwriting.pdf"; // var res = Common.ConverPDFByStream(input, "»ªÏĺ½¿Õˮӡ²âÊÔ"); // //new AWSS3().WritingAnObjectAsync(keyName_new, res).Wait(); // return JsonConvert.SerializeObject(new { input, context }); //} public Function() { // Register any MIME content types you want treated as binary //RegisterResponseContentEncodingForContentType( // "application/octet-stream", // ResponseContentEncoding.Base64); AppFunc = async env => { var context = new LambdaOwinContext(env); context.Response.ContentType = "application/octet-stream"; var res = Common.ConverPDFByStream("test.pdf", "»ªÏĺ½¿Õˮӡ²âÊÔ"); byte[] bytes = new byte[res.Length]; await context.Response.WriteAsync(JsonConvert.SerializeObject(context)); //await context.Response.WriteAsync(new string('a', 100000)); }; }
public SampleFunction() { AppFunc = async env => { var context = new LambdaOwinContext(env); if (context.Request.Path.StartsWithSegments(PathString.FromUriComponent("/img"))) { var stream = typeof(SampleFunction).GetTypeInfo().Assembly .GetManifestResourceStream("Sample.doge.jpg"); context.Response.ContentType = "image/jpeg"; context.Response.ContentLength = stream.Length; context.Response.Body = stream; return; } context.Response.Headers.Append("Content-Type", "text/plain"); var proxyRequest = context.ProxyRequest; await context.Response.WriteAsync(proxyRequest.RequestContext.RequestId); }; }