阿里云官方sdk的 asp.net core 集成方案
First Install the Geexbox.Aliyun.Oss package from NuGet, either using powershell:
Install-Package Geexbox.Aliyun.Oss
or using the .NET CLI:
dotnet add package Geexbox.Aliyun.Oss
in Startup.cs
public IServiceProvider ConfigureServices(IServiceCollection services)
{
// ...
services.AddAliyunOss(options =>
{
options.AccessKeyId = "your_AccessKeyId";
options.AccessKeySecret = "your_AccessKeySecret";
options.BulkName = "your_BulkName";
options.ImageUrlPrefix = "your_ImageUrlPrefix";
});
// ...
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
// ...
app.UseAliyunOss();
// ...
}
the default upload link would be your_site_baseUrl + "/fileupload"
(eg.: http://localhost:8000/fileupload
)