using Amazon; using Amazon.S3; using Amazon.S3.Model; using Microsoft.AspNetCore.Http.Features; var builder = WebApplication.CreateBuilder(args); // Add services to the container. builder.Services.AddControllers(); builder.Services.AddControllersWithViews(); builder.Services.Configure(options => { options.MultipartBodyLengthLimit = 268435456; }); //.NET CORE Aws S3 ʹÓà //https://blog.csdn.net/qq_36694046/article/details/136672057 // ¹Ù·½Îĵµ https://docs.aws.amazon.com/zh_cn/AmazonS3/latest/userguide/optimizing-performance.html var s3Endpoint ="http://192.168.8.160:8080"; var s3AccessKey = "YR3H8OQKRC5PP6JZLYCQ"; var s3SecretKey = "BQFGIB3vzGtdjXETSp5oD0dq28r0wbUwbx9XG2y8"; var s3Configuration = new AmazonS3Config { RegionEndpoint = RegionEndpoint.USEast1, ServiceURL = s3Endpoint, ForcePathStyle = true }; var s3Client=new AmazonS3Client(s3AccessKey, s3SecretKey, s3Configuration); builder.Services.AddSingleton(sp => s3Client); var app = builder.Build(); // Configure the HTTP request pipeline. app.UseHttpsRedirection(); app.UseAuthorization(); app.MapControllers(); app.Run();