Skip to content
This repository has been archived by the owner on Jan 5, 2024. It is now read-only.

Commit

Permalink
feat(TUpload): 新增 TUpload 组件 (#309)
Browse files Browse the repository at this point in the history
  • Loading branch information
teacher-zhou authored Aug 1, 2023
2 parents 8d174c5 + 48434e5 commit aa48395
Show file tree
Hide file tree
Showing 22 changed files with 1,539 additions and 28 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ name: "CodeQL"

on:
push:
branches: [ "master" ]
branches: [ "main" ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ "master" ]
branches: [ "main" ]
schedule:
- cron: '44 21 * * 5'

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy-webassembl-artifact.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Deploy to Artifact
# Run workflow on every push to the master branch
on:
push:
branches: [ master ]
branches: [ main ]

jobs:
Deploy-Artifact:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/draft-release-note.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
push:
# branches to consider in the event; optional, defaults to all
branches:
- master
- [main]
# pull_request event is required only for autolabeler
pull_request:
# Only following types are handled by the action, but one can default to all as well
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/git-pages-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Deploy to GitHub Pages
# Run workflow on every push to the master branch
on:
push:
branches: [ master ]
branches: [ main ]

jobs:
deploy-to-github-pages:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/git-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ name: Git Version
on:
push:
branches:
- master
- [main]

jobs:
lint:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr-commit-label.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: PR conventional labeled

on:
pull_request:
branches: [master]
branches: [main]
types:
[opened, reopened, labeled, unlabeled]

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ env:

on:
push:
branches: [ "master" ]
branches: [ "main" ]
pull_request:
branches: [ "master" ]
branches: [ "main" ]
jobs:
Codacy:
runs-on: ubuntu-latest
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*.user
*.userosscache
*.sln.docstates
[Uu]pload

# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
Expand Down Expand Up @@ -362,4 +363,4 @@ MigrationBackup/
FodyWeavers.xsd
*.pptx
*.vsdx
node_modules
node_modules
30 changes: 30 additions & 0 deletions doc/TDesign.Docs.ServerSide/Controllers/UploadController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using Microsoft.AspNetCore.Components.Forms;
using Microsoft.AspNetCore.Mvc;

namespace TDesign.Docs.ServerSide.Controllers;
[ApiController]
[Route("api/[controller]")]
public class UploadController : ControllerBase
{
[HttpPost("file")]
public async Task<IActionResult> PostAsync([FromForm] IFormCollection form)
{
var savedPath = Path.Combine(Directory.GetCurrentDirectory(), "upload");

if ( !Directory.Exists(savedPath) )
{
Directory.CreateDirectory(savedPath);
}

foreach ( var file in form.Files )
{
var generateFileName = string.Concat(DateTimeOffset.Now.ToString("yyyyMMddHHmmssfff"), Path.GetExtension(file.FileName));
var serverFilePath = Path.Combine(savedPath, generateFileName);

using var fileStream = new FileStream(serverFilePath, FileMode.CreateNew);
await file.OpenReadStream().CopyToAsync(fileStream);
}

return Ok();
}
}
3 changes: 2 additions & 1 deletion doc/TDesign.Docs.ServerSide/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
builder.Services.AddRazorPages();
builder.Services.AddServerSideBlazor();
builder.Services.AddTDesign();
builder.Services.AddControllers();
builder.Services.AddScoped<HttpClient>(hc => new() { BaseAddress = new("http://localhost:5067") });
var app = builder.Build();

Expand All @@ -26,5 +27,5 @@
app.MapRazorPages();
app.MapBlazorHub();
app.MapFallbackToPage("/_Host");

app.MapControllers();
app.Run();
Loading

0 comments on commit aa48395

Please sign in to comment.