Dreamine.Web 1.0.0.0
WPF와 Blazor를 한 코드 흐름으로 연결하고 반복적인 MVVM 코드를 줄이는 오픈소스 FullKit 공식 웹 애플리케이션입니다.
로딩중...
검색중...
일치하는것 없음
DreamineWeb.Services.PlaygroundMediaService 클래스 참조sealed

더 자세히 ...

Public 멤버 함수

 PlaygroundMediaService ()
async Task< string > SaveAsync (IBrowserFile file, string demoId, string platform, CancellationToken ct=default)

정적 Private 멤버 함수

static string SafeSegment (string? value, string fallback)
static string GuessExtension (string? contentType)

Private 속성

readonly string _uploadRoot

정적 Private 속성

static readonly Regex UnsafeName = new(@"[^a-zA-Z0-9._-]+", RegexOptions.Compiled)

상세한 설명

Playground Media Service 기능과 관련 상태를 캡슐화합니다.

PlaygroundMediaService.cs 파일의 15 번째 라인에서 정의되었습니다.

생성자 & 소멸자 문서화

◆ PlaygroundMediaService()

DreamineWeb.Services.PlaygroundMediaService.PlaygroundMediaService ( )
inline

지정한 설정으로 PlaygroundMediaService 클래스의 새 인스턴스를 초기화합니다.

PlaygroundMediaService.cs 파일의 44 번째 라인에서 정의되었습니다.

45 {
46 _uploadRoot = Path.Combine(AppContext.BaseDirectory, "wwwroot", "uploads", "playground");
47 }

다음을 참조함 : _uploadRoot.

멤버 함수 문서화

◆ GuessExtension()

string DreamineWeb.Services.PlaygroundMediaService.GuessExtension ( string? contentType)
inlinestaticprivate

Guess Extension 작업을 수행합니다.

매개변수
contentTypecontent Type에 사용할 string? 값입니다.
반환값
Guess Extension 작업에서 생성한 string 결과입니다.

PlaygroundMediaService.cs 파일의 190 번째 라인에서 정의되었습니다.

190 => contentType?.ToLowerInvariant() switch
191 {
192 "image/png" => ".png",
193 "image/jpeg" => ".jpg",
194 "image/gif" => ".gif",
195 "image/webp" => ".webp",
196 "image/svg+xml" => ".svg",
197 "video/mp4" => ".mp4",
198 "video/webm" => ".webm",
199 "video/quicktime" => ".mov",
200 _ => ".bin"
201 };

다음에 의해서 참조됨 : SaveAsync().

이 함수를 호출하는 함수들에 대한 그래프입니다.:

◆ SafeSegment()

string DreamineWeb.Services.PlaygroundMediaService.SafeSegment ( string? value,
string fallback )
inlinestaticprivate

Safe Segment 작업을 수행합니다.

매개변수
value적용할 값입니다.
fallbackfallback에 사용할 string 값입니다.
반환값
Safe Segment 작업에서 생성한 string 결과입니다.

PlaygroundMediaService.cs 파일의 159 번째 라인에서 정의되었습니다.

160 {
161 value = string.IsNullOrWhiteSpace(value) ? fallback : value.Trim();
162 var safe = UnsafeName.Replace(value, "-").Trim('-', '.');
163 return string.IsNullOrWhiteSpace(safe) ? fallback : safe;
164 }

다음을 참조함 : UnsafeName.

다음에 의해서 참조됨 : SaveAsync().

이 함수를 호출하는 함수들에 대한 그래프입니다.:

◆ SaveAsync()

async Task< string > DreamineWeb.Services.PlaygroundMediaService.SaveAsync ( IBrowserFile file,
string demoId,
string platform,
CancellationToken ct = default )
inline

Async 데이터를 저장합니다.

매개변수
filefile에 사용할 IBrowserFile 값입니다.
demoIddemo Id에 사용할 string 값입니다.
platformplatform에 사용할 string 값입니다.
ct취소 요청을 감시하는 토큰입니다.
반환값
Save Async 작업에서 생성한 Task<string> 결과입니다.
예외
InvalidOperationException현재 객체 상태에서 Save Async 작업을 수행할 수 없는 경우 발생합니다.

PlaygroundMediaService.cs 파일의 105 번째 라인에서 정의되었습니다.

106 {
107 if (file.Size <= 0) throw new InvalidOperationException("Empty files cannot be uploaded.");
108
109 var safeDemoId = SafeSegment(demoId, "demo");
110 var safePlatform = SafeSegment(platform, "platform");
111 var extension = Path.GetExtension(file.Name);
112 if (string.IsNullOrWhiteSpace(extension)) extension = GuessExtension(file.ContentType);
113
114 var targetDir = Path.Combine(_uploadRoot, safeDemoId);
115 Directory.CreateDirectory(targetDir);
116
117 var fileName = $"{safePlatform}-{DateTime.UtcNow:yyyyMMddHHmmss}-{Guid.NewGuid().ToString("N")[..8]}{extension.ToLowerInvariant()}";
118 var path = Path.Combine(targetDir, fileName);
119
120 await using var input = file.OpenReadStream(maxAllowedSize: 200 * 1024 * 1024, cancellationToken: ct);
121 await using var output = File.Create(path);
122 await input.CopyToAsync(output, ct);
123
124 return $"/uploads/playground/{safeDemoId}/{fileName}";
125 }

다음을 참조함 : _uploadRoot, GuessExtension(), SafeSegment().

이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:

멤버 데이터 문서화

◆ _uploadRoot

readonly string DreamineWeb.Services.PlaygroundMediaService._uploadRoot
private

upload Root 값을 보관합니다.

PlaygroundMediaService.cs 파일의 34 번째 라인에서 정의되었습니다.

다음에 의해서 참조됨 : PlaygroundMediaService(), SaveAsync().

◆ UnsafeName

readonly Regex DreamineWeb.Services.PlaygroundMediaService.UnsafeName = new(@"[^a-zA-Z0-9._-]+", RegexOptions.Compiled)
staticprivate

Unsafe Name 값을 보관합니다.

PlaygroundMediaService.cs 파일의 25 번째 라인에서 정의되었습니다.

다음에 의해서 참조됨 : SafeSegment().


이 클래스에 대한 문서화 페이지는 다음의 파일로부터 생성되었습니다.: