diff options
author | emkael <emkael@tlen.pl> | 2018-10-13 16:24:18 +0200 |
---|---|---|
committer | emkael <emkael@tlen.pl> | 2019-10-27 14:52:17 +0100 |
commit | 1d4a0fc3c8ed735cdd9db7df79c66761556c025a (patch) | |
tree | cf069ce05219dd76bbf026fbdb2a314210f21b0f | |
parent | 1c13a9649dc79426fc07ccd4175c7324ab169870 (diff) |
S3 client for file upload
-rw-r--r-- | kurier/S3.cs | 30 | ||||
-rw-r--r-- | kurier/kurier.csproj | 7 |
2 files changed, 37 insertions, 0 deletions
diff --git a/kurier/S3.cs b/kurier/S3.cs new file mode 100644 index 0000000..55993d1 --- /dev/null +++ b/kurier/S3.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Text; +using Amazon.S3; +using Amazon.S3.Model; +using System.IO; +using System.Windows.Forms; +using Amazon; + +namespace kurier +{ + class S3 + { + private AmazonS3Client _client; + + public S3() + { + this._client = new AmazonS3Client(Properties.S3Settings.Default.AWS_ACCESS_KEY, Properties.S3Settings.Default.AWS_SECRET_KEY, RegionEndpoint.EUCentral1); + } + + public void send(string bucket, string filePath, string remotePath) + { + PutObjectRequest request = new PutObjectRequest { + BucketName = bucket, + Key = remotePath, + ContentBody = File.ReadAllText(filePath) }; + this._client.PutObject(request); + } + } +} diff --git a/kurier/kurier.csproj b/kurier/kurier.csproj index 30ec64e..cb3dda9 100644 --- a/kurier/kurier.csproj +++ b/kurier/kurier.csproj @@ -50,6 +50,12 @@ <WarningLevel>4</WarningLevel> </PropertyGroup> <ItemGroup> + <Reference Include="AWSSDK.Core"> + <HintPath>..\res\AWSSDK.Core.dll</HintPath> + </Reference> + <Reference Include="AWSSDK.S3"> + <HintPath>..\res\AWSSDK.S3.dll</HintPath> + </Reference> <Reference Include="MySql.Data, Version=6.9.7.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d, processorArchitecture=MSIL"> <SpecificVersion>False</SpecificVersion> <HintPath>..\res\MySql.Data.dll</HintPath> @@ -80,6 +86,7 @@ </Compile> <Compile Include="Program.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> + <Compile Include="S3.cs" /> <Compile Include="Properties\S3Settings.Designer.cs"> <AutoGen>True</AutoGen> <DesignTimeSharedInput>True</DesignTimeSharedInput> |