Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
40 lines
1.2 KiB
Plaintext
40 lines
1.2 KiB
Plaintext
import { APIError } from '../../errors/APIError.js';
|
|
import { isEligibleRequest } from './isEligibleRequest.js';
|
|
import { processMultipart } from './processMultipart.js';
|
|
import { debugLog } from './utilities.js';
|
|
const DEFAULT_UPLOAD_OPTIONS = {
|
|
abortOnLimit: false,
|
|
createParentPath: false,
|
|
debug: false,
|
|
defParamCharset: 'utf8',
|
|
limitHandler: false,
|
|
parseNested: false,
|
|
preserveExtension: false,
|
|
responseOnLimit: 'File size limit has been reached',
|
|
safeFileNames: false,
|
|
tempFileDir: 'tmp',
|
|
uploadTimeout: 60000,
|
|
uriDecodeFileNames: false,
|
|
useTempFiles: false
|
|
};
|
|
export const processMultipartFormdata = async ({ options: incomingOptions, request })=>{
|
|
const options = {
|
|
...DEFAULT_UPLOAD_OPTIONS,
|
|
...incomingOptions
|
|
};
|
|
if (!isEligibleRequest(request)) {
|
|
debugLog(options, 'Request is not eligible for file upload!');
|
|
return {
|
|
error: new APIError('Request is not eligible for file upload', 500),
|
|
fields: undefined,
|
|
files: undefined
|
|
};
|
|
} else {
|
|
return processMultipart({
|
|
options,
|
|
request
|
|
});
|
|
}
|
|
};
|
|
|
|
//# sourceMappingURL=index.js.map |