Compare commits
2 Commits
main
..
bb5f6d6cd6
| Author | SHA1 | Date | |
|---|---|---|---|
| bb5f6d6cd6 | |||
| 22b9f72198 |
@@ -0,0 +1,63 @@
|
|||||||
|
###############################################################################
|
||||||
|
# Set default behavior to automatically normalize line endings.
|
||||||
|
###############################################################################
|
||||||
|
* text=auto
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# Set default behavior for command prompt diff.
|
||||||
|
#
|
||||||
|
# This is need for earlier builds of msysgit that does not have it on by
|
||||||
|
# default for csharp files.
|
||||||
|
# Note: This is only used by command line
|
||||||
|
###############################################################################
|
||||||
|
#*.cs diff=csharp
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# Set the merge driver for project and solution files
|
||||||
|
#
|
||||||
|
# Merging from the command prompt will add diff markers to the files if there
|
||||||
|
# are conflicts (Merging from VS is not affected by the settings below, in VS
|
||||||
|
# the diff markers are never inserted). Diff markers may cause the following
|
||||||
|
# file extensions to fail to load in VS. An alternative would be to treat
|
||||||
|
# these files as binary and thus will always conflict and require user
|
||||||
|
# intervention with every merge. To do so, just uncomment the entries below
|
||||||
|
###############################################################################
|
||||||
|
#*.sln merge=binary
|
||||||
|
#*.csproj merge=binary
|
||||||
|
#*.vbproj merge=binary
|
||||||
|
#*.vcxproj merge=binary
|
||||||
|
#*.vcproj merge=binary
|
||||||
|
#*.dbproj merge=binary
|
||||||
|
#*.fsproj merge=binary
|
||||||
|
#*.lsproj merge=binary
|
||||||
|
#*.wixproj merge=binary
|
||||||
|
#*.modelproj merge=binary
|
||||||
|
#*.sqlproj merge=binary
|
||||||
|
#*.wwaproj merge=binary
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# behavior for image files
|
||||||
|
#
|
||||||
|
# image files are treated as binary by default.
|
||||||
|
###############################################################################
|
||||||
|
#*.jpg binary
|
||||||
|
#*.png binary
|
||||||
|
#*.gif binary
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# diff behavior for common document formats
|
||||||
|
#
|
||||||
|
# Convert binary document formats to text before diffing them. This feature
|
||||||
|
# is only available from the command line. Turn it on by uncommenting the
|
||||||
|
# entries below.
|
||||||
|
###############################################################################
|
||||||
|
#*.doc diff=astextplain
|
||||||
|
#*.DOC diff=astextplain
|
||||||
|
#*.docx diff=astextplain
|
||||||
|
#*.DOCX diff=astextplain
|
||||||
|
#*.dot diff=astextplain
|
||||||
|
#*.DOT diff=astextplain
|
||||||
|
#*.pdf diff=astextplain
|
||||||
|
#*.PDF diff=astextplain
|
||||||
|
#*.rtf diff=astextplain
|
||||||
|
#*.RTF diff=astextplain
|
||||||
+2
-39
@@ -1,8 +1,7 @@
|
|||||||
# ---> VisualStudio
|
|
||||||
## Ignore Visual Studio temporary files, build results, and
|
## Ignore Visual Studio temporary files, build results, and
|
||||||
## files generated by popular Visual Studio add-ons.
|
## files generated by popular Visual Studio add-ons.
|
||||||
##
|
##
|
||||||
## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore
|
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
|
||||||
|
|
||||||
# User-specific files
|
# User-specific files
|
||||||
*.rsuser
|
*.rsuser
|
||||||
@@ -30,6 +29,7 @@ x86/
|
|||||||
bld/
|
bld/
|
||||||
[Bb]in/
|
[Bb]in/
|
||||||
[Oo]bj/
|
[Oo]bj/
|
||||||
|
[Oo]ut/
|
||||||
[Ll]og/
|
[Ll]og/
|
||||||
[Ll]ogs/
|
[Ll]ogs/
|
||||||
|
|
||||||
@@ -91,7 +91,6 @@ StyleCopReport.xml
|
|||||||
*.tmp_proj
|
*.tmp_proj
|
||||||
*_wpftmp.csproj
|
*_wpftmp.csproj
|
||||||
*.log
|
*.log
|
||||||
*.tlog
|
|
||||||
*.vspscc
|
*.vspscc
|
||||||
*.vssscc
|
*.vssscc
|
||||||
.builds
|
.builds
|
||||||
@@ -295,17 +294,6 @@ node_modules/
|
|||||||
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
|
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
|
||||||
*.vbw
|
*.vbw
|
||||||
|
|
||||||
# Visual Studio 6 auto-generated project file (contains which files were open etc.)
|
|
||||||
*.vbp
|
|
||||||
|
|
||||||
# Visual Studio 6 workspace and project file (working project files containing files to include in project)
|
|
||||||
*.dsw
|
|
||||||
*.dsp
|
|
||||||
|
|
||||||
# Visual Studio 6 technical files
|
|
||||||
*.ncb
|
|
||||||
*.aps
|
|
||||||
|
|
||||||
# Visual Studio LightSwitch build output
|
# Visual Studio LightSwitch build output
|
||||||
**/*.HTMLClient/GeneratedArtifacts
|
**/*.HTMLClient/GeneratedArtifacts
|
||||||
**/*.DesktopClient/GeneratedArtifacts
|
**/*.DesktopClient/GeneratedArtifacts
|
||||||
@@ -362,9 +350,6 @@ ASALocalRun/
|
|||||||
# Local History for Visual Studio
|
# Local History for Visual Studio
|
||||||
.localhistory/
|
.localhistory/
|
||||||
|
|
||||||
# Visual Studio History (VSHistory) files
|
|
||||||
.vshistory/
|
|
||||||
|
|
||||||
# BeatPulse healthcheck temp database
|
# BeatPulse healthcheck temp database
|
||||||
healthchecksdb
|
healthchecksdb
|
||||||
|
|
||||||
@@ -376,25 +361,3 @@ MigrationBackup/
|
|||||||
|
|
||||||
# Fody - auto-generated XML schema
|
# Fody - auto-generated XML schema
|
||||||
FodyWeavers.xsd
|
FodyWeavers.xsd
|
||||||
|
|
||||||
# VS Code files for those working on multiple tools
|
|
||||||
.vscode/*
|
|
||||||
!.vscode/settings.json
|
|
||||||
!.vscode/tasks.json
|
|
||||||
!.vscode/launch.json
|
|
||||||
!.vscode/extensions.json
|
|
||||||
*.code-workspace
|
|
||||||
|
|
||||||
# Local History for Visual Studio Code
|
|
||||||
.history/
|
|
||||||
|
|
||||||
# Windows Installer files from build outputs
|
|
||||||
*.cab
|
|
||||||
*.msi
|
|
||||||
*.msix
|
|
||||||
*.msm
|
|
||||||
*.msp
|
|
||||||
|
|
||||||
# JetBrains Rider
|
|
||||||
*.sln.iml
|
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio Version 17
|
||||||
|
VisualStudioVersion = 17.11.35327.3
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ttalkkak", "Ttalkkak\Ttalkkak.csproj", "{1986B594-0AD0-4ABA-8243-D06F0F85E1A8}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{1986B594-0AD0-4ABA-8243-D06F0F85E1A8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{1986B594-0AD0-4ABA-8243-D06F0F85E1A8}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{1986B594-0AD0-4ABA-8243-D06F0F85E1A8}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{1986B594-0AD0-4ABA-8243-D06F0F85E1A8}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
|
SolutionGuid = {FA1252FD-2B8A-482A-BD96-2EA42BD68EB9}
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
||||||
@@ -0,0 +1,156 @@
|
|||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.IO.Compression;
|
||||||
|
using System.Net;
|
||||||
|
using System.Security.Cryptography;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using K4os.Compression.LZ4.Streams;
|
||||||
|
using Minio;
|
||||||
|
using Minio.DataModel;
|
||||||
|
using Minio.DataModel.Args;
|
||||||
|
using Minio.DataModel.Encryption;
|
||||||
|
using Minio.Exceptions;
|
||||||
|
|
||||||
|
class Program
|
||||||
|
{
|
||||||
|
static async Task Main(string[] args)
|
||||||
|
{
|
||||||
|
//Console.WriteLine("Hello, World!");
|
||||||
|
|
||||||
|
// Minio 설정 (Minio 클라이언트 인스턴스 생성)
|
||||||
|
IWebProxy proxy = new WebProxy("https://a4plane.duckdns.org", 443);
|
||||||
|
IMinioClient minioClient = new MinioClient()
|
||||||
|
.WithEndpoint("a4plane.duckdns.org")
|
||||||
|
.WithCredentials("a4plane", "661434Ghkd")
|
||||||
|
.WithSSL()
|
||||||
|
.WithProxy(proxy)
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
// 압축 및 업로드할 폴더 및 파일 경로 설정
|
||||||
|
string sourceFolder = "testo";
|
||||||
|
string bucketName = "testob";
|
||||||
|
string objectName = "testtt.lz4";
|
||||||
|
string outputLz4File = Path.Combine(Directory.GetCurrentDirectory(), objectName);
|
||||||
|
|
||||||
|
// 폴더를 압축
|
||||||
|
CompressFolderWithProgress(sourceFolder, outputLz4File);
|
||||||
|
|
||||||
|
// 압축한 파일을 Minio로 업로드
|
||||||
|
await UploadWithProgress((MinioClient)minioClient, bucketName, objectName, outputLz4File);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void CompressFolderWithProgress(string sourceFolder, string outputLz4File)
|
||||||
|
{
|
||||||
|
string tempZipFile = Path.GetTempFileName();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// 압축 전 폴더 확인
|
||||||
|
if (!Directory.Exists(sourceFolder))
|
||||||
|
{
|
||||||
|
Console.WriteLine($"오류: '{sourceFolder}' 폴더가 존재하지 않습니다.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (File.Exists(tempZipFile))
|
||||||
|
{
|
||||||
|
Console.WriteLine($"경고: '{tempZipFile}' 파일이 이미 존재합니다. 덮어씁니다.");
|
||||||
|
File.Delete(tempZipFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ZIP 파일 압축
|
||||||
|
ZipFile.CreateFromDirectory(sourceFolder, tempZipFile, CompressionLevel.Fastest, false);
|
||||||
|
Console.WriteLine("ZIP 압축 완료");
|
||||||
|
|
||||||
|
// ZIP -> LZ4 압축
|
||||||
|
var zipFileInfo = new FileInfo(tempZipFile);
|
||||||
|
long zipFileSize = zipFileInfo.Length;
|
||||||
|
long processedSize = 0;
|
||||||
|
|
||||||
|
using var zipFileStream = File.OpenRead(tempZipFile);
|
||||||
|
using var outputFileStream = File.Create(outputLz4File);
|
||||||
|
using var lz4Stream = LZ4Stream.Encode(outputFileStream);
|
||||||
|
|
||||||
|
var buffer = new byte[8192];
|
||||||
|
int bytesRead;
|
||||||
|
while ((bytesRead = zipFileStream.Read(buffer, 0, buffer.Length)) > 0)
|
||||||
|
{
|
||||||
|
lz4Stream.Write(buffer, 0, bytesRead);
|
||||||
|
processedSize += bytesRead;
|
||||||
|
int progress = (int)(100 * processedSize / zipFileSize);
|
||||||
|
Console.Write($"\rLZ4 압축 진행도: {progress}%");
|
||||||
|
}
|
||||||
|
|
||||||
|
Console.WriteLine("\nLZ4 압축 완료");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"오류 발생: {ex.Message}");
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (File.Exists(tempZipFile))
|
||||||
|
{
|
||||||
|
File.Delete(tempZipFile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 폴더의 전체 파일 크기를 계산하는 메서드
|
||||||
|
static long CalculateFolderSize(string folder)
|
||||||
|
{
|
||||||
|
long size = 0;
|
||||||
|
foreach (var filePath in Directory.GetFiles(folder, "*", SearchOption.AllDirectories))
|
||||||
|
{
|
||||||
|
var fileInfo = new FileInfo(filePath);
|
||||||
|
size += fileInfo.Length;
|
||||||
|
}
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
static async Task UploadWithProgress(MinioClient minio, string bucketName, string objectName, string filePath)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Aes aesEncryption = Aes.Create();
|
||||||
|
aesEncryption.KeySize = 256;
|
||||||
|
aesEncryption.GenerateKey();
|
||||||
|
var ssec = new SSEC(aesEncryption.Key);
|
||||||
|
var progress = new Progress<ProgressReport>(progressReport =>
|
||||||
|
{
|
||||||
|
// Progress events are delivered asynchronously (see remark below)
|
||||||
|
Console.WriteLine(
|
||||||
|
$"Percentage: {progressReport.Percentage}% TotalBytesTransferred: {progressReport.TotalBytesTransferred} bytes");
|
||||||
|
if (progressReport.Percentage != 100)
|
||||||
|
Console.SetCursorPosition(0, Console.CursorTop - 1);
|
||||||
|
else Console.WriteLine();
|
||||||
|
});
|
||||||
|
|
||||||
|
var putObjectArgs = new PutObjectArgs()
|
||||||
|
.WithBucket(bucketName)
|
||||||
|
.WithObject(objectName)
|
||||||
|
.WithFileName(filePath)
|
||||||
|
.WithContentType("application/octet-stream")
|
||||||
|
.WithServerSideEncryption(ssec)
|
||||||
|
.WithProgress(progress);
|
||||||
|
if (putObjectArgs == null)
|
||||||
|
{
|
||||||
|
Console.WriteLine("putObjectArgs is null.");
|
||||||
|
return; // 혹은 예외를 던지는 방법으로 조치
|
||||||
|
}
|
||||||
|
if (minio == null)
|
||||||
|
{
|
||||||
|
Console.WriteLine("MinioClient is null.");
|
||||||
|
}
|
||||||
|
Console.WriteLine($"Bucket Name: {bucketName}, Object Name: {objectName}, File Path: {filePath}");
|
||||||
|
|
||||||
|
|
||||||
|
await minio.PutObjectAsync(putObjectArgs);
|
||||||
|
Console.WriteLine($"{objectName} is uploaded successfully.");
|
||||||
|
}
|
||||||
|
catch (MinioException e)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Error occurred: " + e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="K4os.Compression.LZ4" Version="1.3.8" />
|
||||||
|
<PackageReference Include="K4os.Compression.LZ4.Streams" Version="1.3.8" />
|
||||||
|
<PackageReference Include="Minio" Version="6.0.3" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
Reference in New Issue
Block a user