Galaxy Kylin Server v10 sp1 .Net6.0 upload file error access to the path is denied

Previous article: Galaxy Kirin Server v10 sp1 deployment.Net6.0 http https_csdn_aspnet's blog-CSDN blog

Before .NET 6, this could be solved by installing libgdiplus on the Linux server. libgdiplus is the main provider of cross-platform implementation of the native side of System.Drawing.Common and is an open source mono project. Address: GitHub - mono/libgdiplus: C-based implementation of the GDI+ API

Therefore, the solution is of course to install the relevant dependencies:

1、CentOS

via one-click commands

sudo curl https://raw.githubusercontent.com/stulzq/awesome-dotnetcore-image/master/install/centos7.sh|sh

or

yum update
yum install libgdiplus-devel -y
ln -s /usr/lib64/libgdiplus.so /usr/lib/gdiplus.dll
ln -s /usr/lib64/libgdiplus.so /usr/lib64/gdiplus.dll

2. Galaxy Kirin V10 or Ubuntu

via one-click commands

sudo curl https://raw.githubusercontent.com/stulzq/awesome-dotnetcore-image/master/install/ubuntu.sh|sh

or

apt-get update
apt-get install libgdiplus -y
ln -s /usr/lib/libgdiplus.so /usr/lib/gdiplus.dll

3、Docker

Add the RUN command to the Dockerfile, take the official asp.net core runtime image, and use asp.net core 2.2 as an example:

FROM microsoft/dotnet:2.2.0-aspnetcore-runtime
WORKDIR /app
COPY . .
RUN apt-get update -y && apt-get install -y libgdiplus && apt-get clean && ln -s /usr/lib/libgdiplus.so /usr/lib/gdiplus.dll
EXPOSE 80
ENTRYPOINT ["dotnet", "<你的入口程序集>"]

It should be noted that this step of apt-get update is essential, otherwise it will report that libgdiplus cannot be found. And because it is an official image and uses a docker image built with Debain10, it will be very slow when compiling and running the build.

Since my project has been upgraded from NetCore3.1 to Net6.0, refer to the link: NetCore3.1 project upgrade to Net6.0_.net 3.0 .net6 upgrade_csdn_aspnet's blog-CSDN blog 

And the System.Drawing.Common used in the project has been replaced by other solutions. If you have no other solution, please refer to: .NET6 System.Drawing.Common universal solution_csdn_aspnet's blog-CSDN blog 

So I modified the code and output the error message in the swagger page call interface test to facilitate solving specific problems. The tips are as follows: 

 Access to the path '/xxx/xxx' is denied. 或 access to the path xxx is denied

It means that the current user rights are not enough, so you need to use chmod to authorize the wwwroot folder: chmod 777 wwwroot

Among them, 777, all users have read and write permissions. Use swagger again to upload as shown below:

Guess you like

Origin blog.csdn.net/hefeng_aspnet/article/details/132338680