Skip to content

Instantly share code, notes, and snippets.

Jason Farrell xximjasonxx

Block or report user

Report or block xximjasonxx

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View handlesnscheck.cs
var jsonEvent = JObject.Parse(evnt.Records?[0].Sns.Message);
if (jsonEvent.Value<string>("Event") == "s3:TestEvent")
return;
View bucketpolicy.yaml
awBucketPolicy:
Type: AWS::S3::BucketPolicy
Properties:
Bucket: !Ref RawBucket
PolicyDocument:
Statement:
- Action: "s3:Put*"
Effect: Allow
Resource:
Fn::Join:
View createthumbnailrole.yaml
CreateThumbnailFunctionRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Allow
Principal:
AWS: "*"
Service: lambda.amazonaws.com
View api-deployment.yaml
AWSTemplateFormatVersion: 2010-09-09
Description: "Creates infrastructure for Thumnbail Creator"
Resources:
ApiGatewayDeployment:
Type: AWS::ApiGateway::Deployment
Properties:
RestApiId: !Ref ApiGatewayRest
StageName: DefaultDeployment
DependsOn:
View getimages.yaml
AWSTemplateFormatVersion: 2010-09-09
Description: "Creates infrastructure for Thumnbail Creator"
Resources:
ImagesApiMethod:
Type: AWS::ApiGateway::Method
Properties:
RestApiId: !Ref ApiGatewayRest
ResourceId: !Ref ImagesApiResource
HttpMethod: GET
View putobject.yaml
AWSTemplateFormatVersion: 2010-09-09
Description: "Creates infrastructure for Thumnbail Creator"
Resources:
BucketItemApiMethod:
Type: AWS::ApiGateway::Method
Properties:
RestApiId: !Ref ApiGatewayRest
ResourceId: !Ref BucketItemApiResource
HttpMethod: POST
View resource.yaml
AWSTemplateFormatVersion: 2010-09-09
Description: "Creates infrastructure for Thumnbail Creator"
Resources:
BucketApiResource:
Type: AWS::ApiGateway::Resource
Properties:
PathPart: !Ref RawBucketName
RestApiId: !Ref ApiGatewayRest
ParentId: !GetAtt ApiGatewayRest.RootResourceId
View gateway.yaml
AWSTemplateFormatVersion: 2010-09-09
Description: "Creates infrastructure for Thumnbail Creator"
Parameters:
ApiGatewayName:
Type: String
Default: tcapigateway
Description: Enter the name of the API Gateway
Resources:
View analyze.cs
public async Task ExecuteAsync(SNSEvent evnt, ILambdaContext context)
{
var snsData = JsonConvert.DeserializeObject<SnsRecord>(evnt.Records?[0].Sns.Message);
var s3Data = snsData.Records.ElementAt(0).S3;
using (var client = new AmazonRekognitionClient(RegionEndpoint.USEast1))
{
var detectedLabels = await DetectLabelsAsync(client,
s3Data.Bucket.Name,
s3Data.Object.Key);
View function.cs
Stream GetResizedStream(Stream stream, decimal scalingFactor, string mimeType)
{
using (Image<Rgba32> image = Image.Load(stream))
{
var resizeOptions = new ResizeOptions
{
Size = new SixLabors.Primitives.Size
{
Width = Convert.ToInt32(image.Width * scalingFactor),
Height = Convert.ToInt32(image.Height * scalingFactor)
You can’t perform that action at this time.