Skip to content

Commit cae220c

Browse files
add Metadata
1 parent 5fd7bd3 commit cae220c

8 files changed

+72
-205
lines changed

Diff for: Function.cs

+38-10
Original file line numberDiff line numberDiff line change
@@ -140,26 +140,54 @@ public async Task FunctionHandler(S3Event input, ILambdaContext context)
140140
}
141141

142142

143+
144+
await this.S3Client.PutObjectTaggingAsync(new PutObjectTaggingRequest
145+
{
146+
BucketName = record.S3.Bucket.Name,
147+
Key = record.S3.Object.Key,
148+
Tagging = new Tagging
149+
{
150+
TagSet = tags
151+
}
152+
});
153+
154+
byte[] metadata;
155+
using (GetObjectResponse response = await this.S3Client.GetObjectAsync(
156+
record.S3.Bucket.Name,
157+
record.S3.Object.Key))
158+
{
159+
using (Stream responseStream = response.ResponseStream)
160+
{
161+
using (StreamReader reader = new StreamReader(responseStream))
162+
{
163+
using (var memStream = new MemoryStream())
164+
{
165+
var buffer = new byte[512];
166+
var bytesRead = default(int);
167+
168+
while ((bytesRead = reader.BaseStream.Read(buffer, 0, buffer.Length)) > 0)
169+
memStream.Write(buffer, 0, bytesRead);
170+
171+
metadata = memStream.ToArray();
172+
}
173+
}
174+
}
175+
}
176+
143177
MyImage image = new MyImage();
144178
image.BucketName = record.S3.Bucket.Name;
145179
image.KeyName = record.S3.Object.Key;
146180
image.Labels = labels;
147181
image.Processed = false;
148-
image.Metadatainfo = null;
182+
image.Metadata = metadata;
149183

150184
image = new AWSDynamoService(dynamoDBClient).Create(image).Result;
151185

152186
Console.WriteLine($"\tSaved {image.KeyName} with confidence {image.Id}");
153187

154-
/*await this.S3Client.PutObjectTaggingAsync(new PutObjectTaggingRequest
155-
{
156-
BucketName = record.S3.Bucket.Name,
157-
Key = record.S3.Object.Key,
158-
Tagging = new Tagging
159-
{
160-
TagSet = tags
161-
}
162-
});*/
188+
189+
190+
163191
}
164192
return;
165193
}

Diff for: Model/MyImage.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public class MyImage
1919
public bool Processed { get; set; }
2020

2121
[DynamoDBProperty]
22-
public string Metadatainfo { get; set; }
22+
public byte[] Metadata { get; set; }
2323

2424
[DynamoDBProperty(AttributeName = "Labels")]
2525
public List<MyLabel> Labels { get; set; }

Diff for: obj/Assignment4AWSLambda.csproj.nuget.dgspec.json

+7-12
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
{
22
"format": 1,
33
"restore": {
4-
"C:\\Comp306_AWSAmazon\\Lab4\\Assignment4AWSLambda\\Assignment4AWSLambda.csproj": {}
4+
"Z:\\IntelliJ Idea\\Assignment4AWSLambda\\Assignment4AWSLambda.csproj": {}
55
},
66
"projects": {
7-
"C:\\Comp306_AWSAmazon\\Lab4\\Assignment4AWSLambda\\Assignment4AWSLambda.csproj": {
7+
"Z:\\IntelliJ Idea\\Assignment4AWSLambda\\Assignment4AWSLambda.csproj": {
88
"version": "1.0.0",
99
"restore": {
10-
"projectUniqueName": "C:\\Comp306_AWSAmazon\\Lab4\\Assignment4AWSLambda\\Assignment4AWSLambda.csproj",
10+
"projectUniqueName": "Z:\\IntelliJ Idea\\Assignment4AWSLambda\\Assignment4AWSLambda.csproj",
1111
"projectName": "Assignment4AWSLambda",
12-
"projectPath": "C:\\Comp306_AWSAmazon\\Lab4\\Assignment4AWSLambda\\Assignment4AWSLambda.csproj",
13-
"packagesPath": "C:\\Users\\sergi\\.nuget\\packages\\",
14-
"outputPath": "C:\\Comp306_AWSAmazon\\Lab4\\Assignment4AWSLambda\\obj\\",
12+
"projectPath": "Z:\\IntelliJ Idea\\Assignment4AWSLambda\\Assignment4AWSLambda.csproj",
13+
"packagesPath": "C:\\Users\\Caique\\.nuget\\packages\\",
14+
"outputPath": "Z:\\IntelliJ Idea\\Assignment4AWSLambda\\obj\\",
1515
"projectStyle": "PackageReference",
1616
"configFilePaths": [
17-
"C:\\Users\\sergi\\AppData\\Roaming\\NuGet\\NuGet.Config",
17+
"C:\\Users\\Caique\\AppData\\Roaming\\NuGet\\NuGet.Config",
1818
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config"
1919
],
2020
"originalTargetFrameworks": [
@@ -84,11 +84,6 @@
8484
},
8585
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\3.1.402\\RuntimeIdentifierGraph.json"
8686
}
87-
},
88-
"runtimes": {
89-
"linux-x64": {
90-
"#import": []
91-
}
9287
}
9388
}
9489
}

Diff for: obj/Assignment4AWSLambda.csproj.nuget.g.props

+5-5
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<RestoreTool Condition=" '$(RestoreTool)' == '' ">NuGet</RestoreTool>
66
<ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">$(MSBuildThisFileDirectory)project.assets.json</ProjectAssetsFile>
77
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">$(UserProfile)\.nuget\packages\</NuGetPackageRoot>
8-
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">C:\Users\sergi\.nuget\packages\</NuGetPackageFolders>
8+
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">C:\Users\Caique\.nuget\packages\</NuGetPackageFolders>
99
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
1010
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">5.7.0</NuGetToolVersion>
1111
</PropertyGroup>
@@ -16,9 +16,9 @@
1616
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
1717
</PropertyGroup>
1818
<PropertyGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
19-
<PkgAWSSDK_Core Condition=" '$(PkgAWSSDK_Core)' == '' ">C:\Users\sergi\.nuget\packages\awssdk.core\3.5.1.42</PkgAWSSDK_Core>
20-
<PkgAWSSDK_S3 Condition=" '$(PkgAWSSDK_S3)' == '' ">C:\Users\sergi\.nuget\packages\awssdk.s3\3.5.5.2</PkgAWSSDK_S3>
21-
<PkgAWSSDK_Rekognition Condition=" '$(PkgAWSSDK_Rekognition)' == '' ">C:\Users\sergi\.nuget\packages\awssdk.rekognition\3.5.2.15</PkgAWSSDK_Rekognition>
22-
<PkgAWSSDK_DynamoDBv2 Condition=" '$(PkgAWSSDK_DynamoDBv2)' == '' ">C:\Users\sergi\.nuget\packages\awssdk.dynamodbv2\3.5.3</PkgAWSSDK_DynamoDBv2>
19+
<PkgAWSSDK_Core Condition=" '$(PkgAWSSDK_Core)' == '' ">C:\Users\Caique\.nuget\packages\awssdk.core\3.5.1.42</PkgAWSSDK_Core>
20+
<PkgAWSSDK_S3 Condition=" '$(PkgAWSSDK_S3)' == '' ">C:\Users\Caique\.nuget\packages\awssdk.s3\3.5.5.2</PkgAWSSDK_S3>
21+
<PkgAWSSDK_Rekognition Condition=" '$(PkgAWSSDK_Rekognition)' == '' ">C:\Users\Caique\.nuget\packages\awssdk.rekognition\3.5.2.15</PkgAWSSDK_Rekognition>
22+
<PkgAWSSDK_DynamoDBv2 Condition=" '$(PkgAWSSDK_DynamoDBv2)' == '' ">C:\Users\Caique\.nuget\packages\awssdk.dynamodbv2\3.5.3</PkgAWSSDK_DynamoDBv2>
2323
</PropertyGroup>
2424
</Project>
26 Bytes
Binary file not shown.
Binary file not shown.

Diff for: obj/project.assets.json

+6-162
Original file line numberDiff line numberDiff line change
@@ -151,157 +151,6 @@
151151
"lib/netcoreapp2.0/System.Runtime.CompilerServices.Unsafe.dll": {}
152152
}
153153
}
154-
},
155-
".NETCoreApp,Version=v3.1/linux-x64": {
156-
"Amazon.Lambda.Core/1.2.0": {
157-
"type": "package",
158-
"compile": {
159-
"lib/netstandard2.0/Amazon.Lambda.Core.dll": {}
160-
},
161-
"runtime": {
162-
"lib/netstandard2.0/Amazon.Lambda.Core.dll": {}
163-
}
164-
},
165-
"Amazon.Lambda.S3Events/1.2.0": {
166-
"type": "package",
167-
"dependencies": {
168-
"AWSSDK.S3": "3.5.3.5"
169-
},
170-
"compile": {
171-
"lib/netstandard2.0/Amazon.Lambda.S3Events.dll": {}
172-
},
173-
"runtime": {
174-
"lib/netstandard2.0/Amazon.Lambda.S3Events.dll": {}
175-
}
176-
},
177-
"Amazon.Lambda.Serialization.SystemTextJson/2.1.0": {
178-
"type": "package",
179-
"dependencies": {
180-
"Amazon.Lambda.Core": "1.2.0"
181-
},
182-
"compile": {
183-
"lib/netcoreapp3.1/Amazon.Lambda.Serialization.SystemTextJson.dll": {}
184-
},
185-
"runtime": {
186-
"lib/netcoreapp3.1/Amazon.Lambda.Serialization.SystemTextJson.dll": {}
187-
}
188-
},
189-
"AWSSDK.Core/3.5.1.42": {
190-
"type": "package",
191-
"compile": {
192-
"lib/netcoreapp3.1/AWSSDK.Core.dll": {}
193-
},
194-
"runtime": {
195-
"lib/netcoreapp3.1/AWSSDK.Core.dll": {}
196-
}
197-
},
198-
"AWSSDK.DynamoDBv2/3.5.3": {
199-
"type": "package",
200-
"dependencies": {
201-
"AWSSDK.Core": "[3.5.1.34, 3.6.0)"
202-
},
203-
"compile": {
204-
"lib/netcoreapp3.1/AWSSDK.DynamoDBv2.dll": {}
205-
},
206-
"runtime": {
207-
"lib/netcoreapp3.1/AWSSDK.DynamoDBv2.dll": {}
208-
}
209-
},
210-
"AWSSDK.Rekognition/3.5.2.15": {
211-
"type": "package",
212-
"dependencies": {
213-
"AWSSDK.Core": "[3.5.1.42, 3.6.0)"
214-
},
215-
"compile": {
216-
"lib/netcoreapp3.1/AWSSDK.Rekognition.dll": {}
217-
},
218-
"runtime": {
219-
"lib/netcoreapp3.1/AWSSDK.Rekognition.dll": {}
220-
}
221-
},
222-
"AWSSDK.S3/3.5.5.2": {
223-
"type": "package",
224-
"dependencies": {
225-
"AWSSDK.Core": "[3.5.1.42, 3.6.0)"
226-
},
227-
"compile": {
228-
"lib/netcoreapp3.1/AWSSDK.S3.dll": {}
229-
},
230-
"runtime": {
231-
"lib/netcoreapp3.1/AWSSDK.S3.dll": {}
232-
}
233-
},
234-
"GrapeCity.Documents.Common/3.0.0.415": {
235-
"type": "package",
236-
"compile": {
237-
"lib/netstandard2.0/GrapeCity.Documents.Common.dll": {}
238-
},
239-
"runtime": {
240-
"lib/netstandard2.0/GrapeCity.Documents.Common.dll": {}
241-
},
242-
"resource": {
243-
"lib/netstandard2.0/ja/GrapeCity.Documents.Common.resources.dll": {
244-
"locale": "ja"
245-
}
246-
}
247-
},
248-
"GrapeCity.Documents.Imaging/3.0.0.415": {
249-
"type": "package",
250-
"dependencies": {
251-
"GrapeCity.Documents.Common": "[3.0.0.415]",
252-
"System.Buffers": "4.4.0",
253-
"System.Memory": "4.5.0",
254-
"System.Numerics.Vectors": "4.4.0",
255-
"System.Runtime.CompilerServices.Unsafe": "4.5.0"
256-
},
257-
"compile": {
258-
"lib/netstandard2.0/GrapeCity.Documents.Imaging.dll": {}
259-
},
260-
"runtime": {
261-
"lib/netstandard2.0/GrapeCity.Documents.Imaging.dll": {}
262-
},
263-
"resource": {
264-
"lib/netstandard2.0/ja/GrapeCity.Documents.Imaging.resources.dll": {
265-
"locale": "ja"
266-
}
267-
}
268-
},
269-
"System.Buffers/4.4.0": {
270-
"type": "package",
271-
"compile": {
272-
"ref/netcoreapp2.0/_._": {}
273-
},
274-
"runtime": {
275-
"lib/netcoreapp2.0/_._": {}
276-
}
277-
},
278-
"System.Memory/4.5.0": {
279-
"type": "package",
280-
"compile": {
281-
"ref/netcoreapp2.1/_._": {}
282-
},
283-
"runtime": {
284-
"lib/netcoreapp2.1/_._": {}
285-
}
286-
},
287-
"System.Numerics.Vectors/4.4.0": {
288-
"type": "package",
289-
"compile": {
290-
"ref/netcoreapp2.0/_._": {}
291-
},
292-
"runtime": {
293-
"lib/netcoreapp2.0/_._": {}
294-
}
295-
},
296-
"System.Runtime.CompilerServices.Unsafe/4.5.0": {
297-
"type": "package",
298-
"compile": {
299-
"ref/netstandard2.0/System.Runtime.CompilerServices.Unsafe.dll": {}
300-
},
301-
"runtime": {
302-
"lib/netcoreapp2.0/System.Runtime.CompilerServices.Unsafe.dll": {}
303-
}
304-
}
305154
}
306155
},
307156
"libraries": {
@@ -647,19 +496,19 @@
647496
]
648497
},
649498
"packageFolders": {
650-
"C:\\Users\\sergi\\.nuget\\packages\\": {}
499+
"C:\\Users\\Caique\\.nuget\\packages\\": {}
651500
},
652501
"project": {
653502
"version": "1.0.0",
654503
"restore": {
655-
"projectUniqueName": "C:\\Comp306_AWSAmazon\\Lab4\\Assignment4AWSLambda\\Assignment4AWSLambda.csproj",
504+
"projectUniqueName": "Z:\\IntelliJ Idea\\Assignment4AWSLambda\\Assignment4AWSLambda.csproj",
656505
"projectName": "Assignment4AWSLambda",
657-
"projectPath": "C:\\Comp306_AWSAmazon\\Lab4\\Assignment4AWSLambda\\Assignment4AWSLambda.csproj",
658-
"packagesPath": "C:\\Users\\sergi\\.nuget\\packages\\",
659-
"outputPath": "C:\\Comp306_AWSAmazon\\Lab4\\Assignment4AWSLambda\\obj\\",
506+
"projectPath": "Z:\\IntelliJ Idea\\Assignment4AWSLambda\\Assignment4AWSLambda.csproj",
507+
"packagesPath": "C:\\Users\\Caique\\.nuget\\packages\\",
508+
"outputPath": "Z:\\IntelliJ Idea\\Assignment4AWSLambda\\obj\\",
660509
"projectStyle": "PackageReference",
661510
"configFilePaths": [
662-
"C:\\Users\\sergi\\AppData\\Roaming\\NuGet\\NuGet.Config",
511+
"C:\\Users\\Caique\\AppData\\Roaming\\NuGet\\NuGet.Config",
663512
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config"
664513
],
665514
"originalTargetFrameworks": [
@@ -729,11 +578,6 @@
729578
},
730579
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\3.1.402\\RuntimeIdentifierGraph.json"
731580
}
732-
},
733-
"runtimes": {
734-
"linux-x64": {
735-
"#import": []
736-
}
737581
}
738582
}
739583
}

Diff for: obj/project.nuget.cache

+15-15
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
{
22
"version": 2,
3-
"dgSpecHash": "NoABLN25MYefQEkGicSukKFAIhIpdLuNv5qSVF2blAMj5DLoaXU44SCtICSa4XMvN2B8CbSj5Jml2LNg5+t3QA==",
3+
"dgSpecHash": "qW70EPvDSTI23rk2+vFKRBgsU3/hAAvo82T4xm+dXTuJTFwgDH5g3ev3DBzISzpIc/rhoCma/m4cVXYZrTrgRg==",
44
"success": true,
5-
"projectFilePath": "C:\\Comp306_AWSAmazon\\Lab4\\Assignment4AWSLambda\\Assignment4AWSLambda.csproj",
5+
"projectFilePath": "Z:\\IntelliJ Idea\\Assignment4AWSLambda\\Assignment4AWSLambda.csproj",
66
"expectedPackageFiles": [
7-
"C:\\Users\\sergi\\.nuget\\packages\\amazon.lambda.core\\1.2.0\\amazon.lambda.core.1.2.0.nupkg.sha512",
8-
"C:\\Users\\sergi\\.nuget\\packages\\amazon.lambda.s3events\\1.2.0\\amazon.lambda.s3events.1.2.0.nupkg.sha512",
9-
"C:\\Users\\sergi\\.nuget\\packages\\amazon.lambda.serialization.systemtextjson\\2.1.0\\amazon.lambda.serialization.systemtextjson.2.1.0.nupkg.sha512",
10-
"C:\\Users\\sergi\\.nuget\\packages\\awssdk.core\\3.5.1.42\\awssdk.core.3.5.1.42.nupkg.sha512",
11-
"C:\\Users\\sergi\\.nuget\\packages\\awssdk.dynamodbv2\\3.5.3\\awssdk.dynamodbv2.3.5.3.nupkg.sha512",
12-
"C:\\Users\\sergi\\.nuget\\packages\\awssdk.rekognition\\3.5.2.15\\awssdk.rekognition.3.5.2.15.nupkg.sha512",
13-
"C:\\Users\\sergi\\.nuget\\packages\\awssdk.s3\\3.5.5.2\\awssdk.s3.3.5.5.2.nupkg.sha512",
14-
"C:\\Users\\sergi\\.nuget\\packages\\grapecity.documents.common\\3.0.0.415\\grapecity.documents.common.3.0.0.415.nupkg.sha512",
15-
"C:\\Users\\sergi\\.nuget\\packages\\grapecity.documents.imaging\\3.0.0.415\\grapecity.documents.imaging.3.0.0.415.nupkg.sha512",
16-
"C:\\Users\\sergi\\.nuget\\packages\\system.buffers\\4.4.0\\system.buffers.4.4.0.nupkg.sha512",
17-
"C:\\Users\\sergi\\.nuget\\packages\\system.memory\\4.5.0\\system.memory.4.5.0.nupkg.sha512",
18-
"C:\\Users\\sergi\\.nuget\\packages\\system.numerics.vectors\\4.4.0\\system.numerics.vectors.4.4.0.nupkg.sha512",
19-
"C:\\Users\\sergi\\.nuget\\packages\\system.runtime.compilerservices.unsafe\\4.5.0\\system.runtime.compilerservices.unsafe.4.5.0.nupkg.sha512"
7+
"C:\\Users\\Caique\\.nuget\\packages\\amazon.lambda.core\\1.2.0\\amazon.lambda.core.1.2.0.nupkg.sha512",
8+
"C:\\Users\\Caique\\.nuget\\packages\\amazon.lambda.s3events\\1.2.0\\amazon.lambda.s3events.1.2.0.nupkg.sha512",
9+
"C:\\Users\\Caique\\.nuget\\packages\\amazon.lambda.serialization.systemtextjson\\2.1.0\\amazon.lambda.serialization.systemtextjson.2.1.0.nupkg.sha512",
10+
"C:\\Users\\Caique\\.nuget\\packages\\awssdk.core\\3.5.1.42\\awssdk.core.3.5.1.42.nupkg.sha512",
11+
"C:\\Users\\Caique\\.nuget\\packages\\awssdk.dynamodbv2\\3.5.3\\awssdk.dynamodbv2.3.5.3.nupkg.sha512",
12+
"C:\\Users\\Caique\\.nuget\\packages\\awssdk.rekognition\\3.5.2.15\\awssdk.rekognition.3.5.2.15.nupkg.sha512",
13+
"C:\\Users\\Caique\\.nuget\\packages\\awssdk.s3\\3.5.5.2\\awssdk.s3.3.5.5.2.nupkg.sha512",
14+
"C:\\Users\\Caique\\.nuget\\packages\\grapecity.documents.common\\3.0.0.415\\grapecity.documents.common.3.0.0.415.nupkg.sha512",
15+
"C:\\Users\\Caique\\.nuget\\packages\\grapecity.documents.imaging\\3.0.0.415\\grapecity.documents.imaging.3.0.0.415.nupkg.sha512",
16+
"C:\\Users\\Caique\\.nuget\\packages\\system.buffers\\4.4.0\\system.buffers.4.4.0.nupkg.sha512",
17+
"C:\\Users\\Caique\\.nuget\\packages\\system.memory\\4.5.0\\system.memory.4.5.0.nupkg.sha512",
18+
"C:\\Users\\Caique\\.nuget\\packages\\system.numerics.vectors\\4.4.0\\system.numerics.vectors.4.4.0.nupkg.sha512",
19+
"C:\\Users\\Caique\\.nuget\\packages\\system.runtime.compilerservices.unsafe\\4.5.0\\system.runtime.compilerservices.unsafe.4.5.0.nupkg.sha512"
2020
],
2121
"logs": []
2222
}

0 commit comments

Comments
 (0)