다른 입력 이름의 이미지 파일이 여러 개있는 제출 된 양식의 파일을 업로드하려고합니다.skippper (sails.js)와 다른 알 수없는 입력 필드 이름이있는 미들웨어 파일 처리
텍스트 입력 및 파일 입력과 다중 양식을 asumming 예를 들어, 및 그룹 같은 이름을 가진 모든 파일 입력에의 실용적이지, 예를 들어 images[]
내가 표현을 만들
<form ...>
some text inputs...
<input type='file' name='logo'/>
<input type='file' name='image-1'/>
<input type='file' name='image-2'/>
</form>
/돛 미들웨어 업로드를 처리하기 위해 컨트롤러에 직접 액세스 할 수 있습니다.
난 (req.file에 그 업로드 방법 (가정) promisified한다)이 오류가 발생합니다
async function(req, res, next){
const maxTimeToBuffer = 9500
const dirname = '/some-upload-path'
const uploads = [
await req.file('logo').upload(dirname, maxTimeToBuffer)
await req.file('image-1').upload(dirname, maxTimeToBuffer)
await req.file('image-2').upload(dirname, maxTimeToBuffer)
]
// attaching the uploads to the request body ...
next()
}
이 작업을 수행 할 경우 EMAXBUFFER: An Upstream (
이미지-1 ) timed out before it was plugged into a receiver. It was still unused after waiting 9500ms. You can configure this timeout by changing the
maxTimeToBuffer option.
그것은 '아무튼를 Skipper 모듈 자체에서도 maxTimeToBuffer
을 30000으로 늘리면 문제가 없습니다.
순차적 방식으로 각 파일을 처리하려고하면 입력 필드 이름을 알고있는 한 아무 문제없이 병렬 처리로 오류를 던집니다.
async function(req, res, next){
const maxTimeToBuffer = 9500
const dirname = '/some-upload-path'
const uploads = await [
req.file('logo').upload(dirname, maxTimeToBuffer)
req.file('image-1').upload(dirname, maxTimeToBuffer)
req.file('image-2').upload(dirname, maxTimeToBuffer)
]
// attaching the uploads to the request body ...
next()
}
이제 입력란을 미리 알지 못해도 마지막 스 니펫에서 어떻게 동일한 결과를 얻을 수 있습니까? 이
async function(req, res, next){
const maxTimeToBuffer = 9500
const dirname = '/some-upload-path'
const uploads = await req._fileparser.upstreams
// attaching the uploads to the request body ...
next()
}
것은 같은 뭔가 req._fileparser.upstreams
이 새로운 스트림을 수신하고 첫 번째 이미지가 완전히 수신 된 후 그 만 일어날 것 (연속)하지만 난이 업스트림을 기다리는 경우 배열이 완료 될 때마다 업데이트되는 것입니다 시간 초과 오류도 발생합니다.
해결 방법이 있습니까?
나는 더 많은 설명이 필요한 경우 알려주는 것이 많다는 것을 안다. 어떤 생각이라도 반갑습니다.