Код: Выделить всё
POST https://apis.mysite.com/apis/auth/ads net::ERR_FAILED 413 (Payload Too Large)
В настройках Nginx я указал:
Код: Выделить всё
client_max_body_size 100M;
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
ssl_certificate ./ssl/mysite.crt;
ssl_certificate_key ./ssl/mysite.key;
client_max_body_size 100M;
upstream apispring {
server 127.0.0.1:8080;
}
server {
listen 443 ssl;
server_name apis.mysite.com;
location / {
proxy_pass http://apispring;
}
}
server {
listen 443 ssl;
server_name mysite.com www.mysite.com;
location / {
root html;
try_files $uri $uri$args $uri$args/ /index.html;
}
}
}
Код: Выделить всё
server.port = 8080
server.tomcat.threads.max = 200
server.tomcat.connection-timeout = 5s
server.tomcat.max-swallow-size = 2MB
server.tomcat.max-http-form-post-size = 50MB
server.max-http-request-header-size = 8KB
spring.servlet.multipart.max-file-size = 50MB
spring.servlet.multipart.max-request-size = 50MB
Код: Выделить всё
previewImages: Set = new Set();
submit() {
const ads: any = {
phone: '1111111111',
email: [email protected],
}
const formData = new FormData();
formData.append('ads', JSON.stringify(ads))
let num = this.previewImages.size;
let count: number = 0
for (const [value] of this.previewImages.entries()) {
formData.append(`img${count}`, value)
count = count + 1
if (count === num) {
count = 0
}
}
this.httpRS.addAds(formData).subscribe({
next: () => {
//
}
});
}
Код: Выделить всё
@RestController
@RequestMapping("/apis/auth")
public class Ads {
@PostMapping(value = "/ads", produces = "application/json")
public viod addAds(@RequestParam(value = "img0", required = false) String img1,
@RequestParam(value = "img1", required = false) String img2,
@RequestParam(value = "ads") String ads) {
// body
}
}
Подробнее здесь: https://stackoverflow.com/questions/774 ... e-in-nginx