|
|
|
@ -2,15 +2,16 @@ using Infrastructure.Extensions;
|
|
|
|
|
using Microsoft.AspNetCore.Hosting;
|
|
|
|
|
using Microsoft.AspNetCore.Http;
|
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
using Microsoft.AspNetCore.StaticFiles;
|
|
|
|
|
using Microsoft.Extensions.Configuration;
|
|
|
|
|
using Minio;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Globalization;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.IO.Compression;
|
|
|
|
|
using System.Net.Http;
|
|
|
|
|
using System.Security.Cryptography;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
|
|
namespace Infrastructure.Web.Mvc
|
|
|
|
|
{
|
|
|
|
@ -96,9 +97,9 @@ namespace Infrastructure.Web.Mvc
|
|
|
|
|
private string UploadMinIO(IFormFile file)
|
|
|
|
|
{
|
|
|
|
|
using var stream = file.OpenReadStream();
|
|
|
|
|
var ext = GetExtension(file.FileName);
|
|
|
|
|
var ext = Path.GetExtension(file.FileName);
|
|
|
|
|
var md5 = GetFileNameHash(stream);
|
|
|
|
|
var name = $"{md5}.{ext}";
|
|
|
|
|
var name = $"{md5}{ext}";
|
|
|
|
|
var endpoint = this._cfg["minio:endpoint"];
|
|
|
|
|
var accessKey = this._cfg["minio:accessKey"];
|
|
|
|
|
var secretKey = this._cfg["minio:secretKey"];
|
|
|
|
@ -139,7 +140,8 @@ namespace Infrastructure.Web.Mvc
|
|
|
|
|
{
|
|
|
|
|
ex.PrintStack();
|
|
|
|
|
stream.Position = 0;
|
|
|
|
|
minio.PutObjectAsync(bucketName, name, stream, stream.Length);
|
|
|
|
|
new FileExtensionContentTypeProvider().Mappings.TryGetValue(ext, out string contenttype);
|
|
|
|
|
minio.PutObjectAsync(bucketName, name, stream, stream.Length, contenttype);
|
|
|
|
|
}
|
|
|
|
|
var path = $"/{bucketName}/{name}";
|
|
|
|
|
return $"/dfs{path}";
|
|
|
|
|