problem description
nginx100KB
nginxnode
the environmental background of the problems and what methods you have tried
Windows,nginx
Apache
related codes
/ / Please paste the code text below (do not replace the code with pictures)
async upload_Img() {
console.log("");
const {
ctx
} = this;
const stream = await ctx.getFileStream();
if (!stream) {
ctx.throw(403, "");
return false;
}
const date = await this.fliteDate(new Date());
const folder = `app/public/upload/img/${date}`;
const filename = new Date().getTime() + stream.filename;
const target = path.join(`${folder}/${filename}`);
let data = {};
const result = await new Promise((resolve, reject) => {
fs.access(folder, fs.constants.F_OK, err => {
if (err) {
fs.mkdir(folder);
}
const remoteFileStream = fs.createWriteStream(target);
const upwin = stream.pipe(remoteFileStream);
console.log("");
console.log(upwin);
if (upwin) {
const path = upwin.path.match(/public(.*)/g);
data = {
code: 0,
msg: "",
data: {
src: ctx.app.config.hostConfig.host + path[0]
}
};
resolve(data);
}
reject("");
});
});
return result;
}
Nginx configuration
http {
include mime.types;
default_type application/octet-stream;
-sharplog_format main "$remote_addr - $remote_user [$time_local] "$request" "
-sharp "$status $body_bytes_sent "$http_referer" "
-sharp ""$http_user_agent" "$http_x_forwarded_for"";
-sharpaccess_log logs/access.log main;
sendfile on;
-sharptcp_nopush on;
client_max_body_size 100M;
-sharpkeepalive_timeout 0;
keepalive_timeout 65;
gzip on;
server {
listen 8099;
location / {
root F:\kcyygzh\app\public;
index index.html;
try_files $uri $uri/ /index.html;
}
location ^~ /admin {
proxy_pass http://localhost:7001;
}
location ^~ /public {
proxy_pass http://localhost:7001;
}
location ^~ /v1 {
proxy_pass http://localhost:7001;
}
location ^~ /api {
proxy_pass http://localhost:7001;
}
location ^~ /home {
proxy_pass http://localhost:7001;
}
error_page 500 502 503 504 404 /50x.html;
location = /50x.html {
root html;
}
}