payload 3.84.0-canary.0 → 3.84.0-internal.d5d6e43

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"isEligibleRequest.d.ts","sourceRoot":"","sources":["../../../src/uploads/fetchAPI-multipart/isEligibleRequest.ts"],"names":[],"mappings":"AAkBA,eAAO,MAAM,iBAAiB,QAAS,OAAO,KAAG,OAMhD,CAAA"}
1
+ {"version":3,"file":"isEligibleRequest.d.ts","sourceRoot":"","sources":["../../../src/uploads/fetchAPI-multipart/isEligibleRequest.ts"],"names":[],"mappings":"AAmBA,eAAO,MAAM,iBAAiB,QAAS,OAAO,KAAG,OAMhD,CAAA"}
@@ -9,7 +9,8 @@ const UNACCEPTABLE_METHODS = new Set([
9
9
  'TRACE'
10
10
  ]);
11
11
  const hasBody = (req)=>{
12
- return Boolean(req.headers.get('transfer-encoding') || req.headers.get('content-length') && req.headers.get('content-length') !== '0');
12
+ const contentLength = req.headers.get('content-length');
13
+ return Boolean(req.body || req.headers.get('transfer-encoding') || contentLength && contentLength !== '0');
13
14
  };
14
15
  const hasAcceptableMethod = (req)=>!UNACCEPTABLE_METHODS.has(req.method);
15
16
  const hasAcceptableContentType = (req)=>{
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/uploads/fetchAPI-multipart/isEligibleRequest.ts"],"sourcesContent":["// eslint-disable-next-line regexp/no-super-linear-backtracking, regexp/no-obscure-range\nconst ACCEPTABLE_CONTENT_TYPE = /multipart\\/['\"()+-_]+(?:; ?['\"()+-_]*)+$/i\nconst UNACCEPTABLE_METHODS = new Set(['CONNECT', 'DELETE', 'GET', 'HEAD', 'OPTIONS', 'TRACE'])\n\nconst hasBody = (req: Request): boolean => {\n return Boolean(\n req.headers.get('transfer-encoding') ||\n (req.headers.get('content-length') && req.headers.get('content-length') !== '0'),\n )\n}\n\nconst hasAcceptableMethod = (req: Request): boolean => !UNACCEPTABLE_METHODS.has(req.method)\n\nconst hasAcceptableContentType = (req: Request): boolean => {\n const contType = req.headers.get('content-type')\n return contType!.includes('boundary=') && ACCEPTABLE_CONTENT_TYPE.test(contType!)\n}\n\nexport const isEligibleRequest = (req: Request): boolean => {\n try {\n return hasBody(req) && hasAcceptableMethod(req) && hasAcceptableContentType(req)\n } catch (ignore) {\n return false\n }\n}\n"],"names":["ACCEPTABLE_CONTENT_TYPE","UNACCEPTABLE_METHODS","Set","hasBody","req","Boolean","headers","get","hasAcceptableMethod","has","method","hasAcceptableContentType","contType","includes","test","isEligibleRequest","ignore"],"mappings":"AAAA,wFAAwF;AACxF,MAAMA,0BAA0B;AAChC,MAAMC,uBAAuB,IAAIC,IAAI;IAAC;IAAW;IAAU;IAAO;IAAQ;IAAW;CAAQ;AAE7F,MAAMC,UAAU,CAACC;IACf,OAAOC,QACLD,IAAIE,OAAO,CAACC,GAAG,CAAC,wBACbH,IAAIE,OAAO,CAACC,GAAG,CAAC,qBAAqBH,IAAIE,OAAO,CAACC,GAAG,CAAC,sBAAsB;AAElF;AAEA,MAAMC,sBAAsB,CAACJ,MAA0B,CAACH,qBAAqBQ,GAAG,CAACL,IAAIM,MAAM;AAE3F,MAAMC,2BAA2B,CAACP;IAChC,MAAMQ,WAAWR,IAAIE,OAAO,CAACC,GAAG,CAAC;IACjC,OAAOK,SAAUC,QAAQ,CAAC,gBAAgBb,wBAAwBc,IAAI,CAACF;AACzE;AAEA,OAAO,MAAMG,oBAAoB,CAACX;IAChC,IAAI;QACF,OAAOD,QAAQC,QAAQI,oBAAoBJ,QAAQO,yBAAyBP;IAC9E,EAAE,OAAOY,QAAQ;QACf,OAAO;IACT;AACF,EAAC"}
1
+ {"version":3,"sources":["../../../src/uploads/fetchAPI-multipart/isEligibleRequest.ts"],"sourcesContent":["// eslint-disable-next-line regexp/no-super-linear-backtracking, regexp/no-obscure-range\nconst ACCEPTABLE_CONTENT_TYPE = /multipart\\/['\"()+-_]+(?:; ?['\"()+-_]*)+$/i\nconst UNACCEPTABLE_METHODS = new Set(['CONNECT', 'DELETE', 'GET', 'HEAD', 'OPTIONS', 'TRACE'])\n\nconst hasBody = (req: Request): boolean => {\n const contentLength = req.headers.get('content-length')\n\n return Boolean(\n req.body || req.headers.get('transfer-encoding') || (contentLength && contentLength !== '0'),\n )\n}\n\nconst hasAcceptableMethod = (req: Request): boolean => !UNACCEPTABLE_METHODS.has(req.method)\n\nconst hasAcceptableContentType = (req: Request): boolean => {\n const contType = req.headers.get('content-type')\n return contType!.includes('boundary=') && ACCEPTABLE_CONTENT_TYPE.test(contType!)\n}\n\nexport const isEligibleRequest = (req: Request): boolean => {\n try {\n return hasBody(req) && hasAcceptableMethod(req) && hasAcceptableContentType(req)\n } catch (ignore) {\n return false\n }\n}\n"],"names":["ACCEPTABLE_CONTENT_TYPE","UNACCEPTABLE_METHODS","Set","hasBody","req","contentLength","headers","get","Boolean","body","hasAcceptableMethod","has","method","hasAcceptableContentType","contType","includes","test","isEligibleRequest","ignore"],"mappings":"AAAA,wFAAwF;AACxF,MAAMA,0BAA0B;AAChC,MAAMC,uBAAuB,IAAIC,IAAI;IAAC;IAAW;IAAU;IAAO;IAAQ;IAAW;CAAQ;AAE7F,MAAMC,UAAU,CAACC;IACf,MAAMC,gBAAgBD,IAAIE,OAAO,CAACC,GAAG,CAAC;IAEtC,OAAOC,QACLJ,IAAIK,IAAI,IAAIL,IAAIE,OAAO,CAACC,GAAG,CAAC,wBAAyBF,iBAAiBA,kBAAkB;AAE5F;AAEA,MAAMK,sBAAsB,CAACN,MAA0B,CAACH,qBAAqBU,GAAG,CAACP,IAAIQ,MAAM;AAE3F,MAAMC,2BAA2B,CAACT;IAChC,MAAMU,WAAWV,IAAIE,OAAO,CAACC,GAAG,CAAC;IACjC,OAAOO,SAAUC,QAAQ,CAAC,gBAAgBf,wBAAwBgB,IAAI,CAACF;AACzE;AAEA,OAAO,MAAMG,oBAAoB,CAACb;IAChC,IAAI;QACF,OAAOD,QAAQC,QAAQM,oBAAoBN,QAAQS,yBAAyBT;IAC9E,EAAE,OAAOc,QAAQ;QACf,OAAO;IACT;AACF,EAAC"}
@@ -0,0 +1,29 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { isEligibleRequest } from './isEligibleRequest.js';
3
+ describe('isEligibleRequest', ()=>{
4
+ it('should accept multipart POST requests with a body stream when content-length is absent', ()=>{
5
+ const formData = new FormData();
6
+ formData.append('file', new Blob([
7
+ 'hello world'
8
+ ], {
9
+ type: 'text/plain'
10
+ }), 'hello.txt');
11
+ const request = new Request('http://localhost/api/upload', {
12
+ body: formData,
13
+ method: 'POST'
14
+ });
15
+ expect(request.headers.get('content-length')).toBeNull();
16
+ expect(isEligibleRequest(request)).toBe(true);
17
+ });
18
+ it('should reject multipart POST requests when no body is present', ()=>{
19
+ const request = new Request('http://localhost/api/upload', {
20
+ headers: {
21
+ 'content-type': 'multipart/form-data; boundary=----test-boundary'
22
+ },
23
+ method: 'POST'
24
+ });
25
+ expect(isEligibleRequest(request)).toBe(false);
26
+ });
27
+ });
28
+
29
+ //# sourceMappingURL=isEligibleRequest.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/uploads/fetchAPI-multipart/isEligibleRequest.spec.ts"],"sourcesContent":["import { describe, expect, it } from 'vitest'\n\nimport { isEligibleRequest } from './isEligibleRequest.js'\n\ndescribe('isEligibleRequest', () => {\n it('should accept multipart POST requests with a body stream when content-length is absent', () => {\n const formData = new FormData()\n formData.append('file', new Blob(['hello world'], { type: 'text/plain' }), 'hello.txt')\n\n const request = new Request('http://localhost/api/upload', {\n body: formData,\n method: 'POST',\n })\n\n expect(request.headers.get('content-length')).toBeNull()\n expect(isEligibleRequest(request)).toBe(true)\n })\n\n it('should reject multipart POST requests when no body is present', () => {\n const request = new Request('http://localhost/api/upload', {\n headers: {\n 'content-type': 'multipart/form-data; boundary=----test-boundary',\n },\n method: 'POST',\n })\n\n expect(isEligibleRequest(request)).toBe(false)\n })\n})\n"],"names":["describe","expect","it","isEligibleRequest","formData","FormData","append","Blob","type","request","Request","body","method","headers","get","toBeNull","toBe"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ,SAAQ;AAE7C,SAASC,iBAAiB,QAAQ,yBAAwB;AAE1DH,SAAS,qBAAqB;IAC5BE,GAAG,0FAA0F;QAC3F,MAAME,WAAW,IAAIC;QACrBD,SAASE,MAAM,CAAC,QAAQ,IAAIC,KAAK;YAAC;SAAc,EAAE;YAAEC,MAAM;QAAa,IAAI;QAE3E,MAAMC,UAAU,IAAIC,QAAQ,+BAA+B;YACzDC,MAAMP;YACNQ,QAAQ;QACV;QAEAX,OAAOQ,QAAQI,OAAO,CAACC,GAAG,CAAC,mBAAmBC,QAAQ;QACtDd,OAAOE,kBAAkBM,UAAUO,IAAI,CAAC;IAC1C;IAEAd,GAAG,iEAAiE;QAClE,MAAMO,UAAU,IAAIC,QAAQ,+BAA+B;YACzDG,SAAS;gBACP,gBAAgB;YAClB;YACAD,QAAQ;QACV;QAEAX,OAAOE,kBAAkBM,UAAUO,IAAI,CAAC;IAC1C;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"processMultipart.d.ts","sourceRoot":"","sources":["../../../src/uploads/fetchAPI-multipart/processMultipart.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAA;AACtE,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,YAAY,CAAA;AAS5D,QAAA,MAAM,iBAAiB,eAAuC,CAAA;AAE9D,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,OAAO;QACf,CAAC,iBAAiB,CAAC,CAAC,EAAE,OAAO,CAAC,GAAG,CAAC,EAAE,CAAA;KACrC;CACF;AAED,KAAK,gBAAgB,GAAG,CAAC,IAAI,EAAE;IAC7B,OAAO,EAAE,yBAAyB,CAAA;IAClC,OAAO,EAAE,OAAO,CAAA;CACjB,KAAK,OAAO,CAAC,0BAA0B,CAAC,CAAA;AACzC,eAAO,MAAM,gBAAgB,EAAE,gBAwM9B,CAAA"}
1
+ {"version":3,"file":"processMultipart.d.ts","sourceRoot":"","sources":["../../../src/uploads/fetchAPI-multipart/processMultipart.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAA;AACtE,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,YAAY,CAAA;AAS5D,QAAA,MAAM,iBAAiB,eAAuC,CAAA;AAE9D,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,OAAO;QACf,CAAC,iBAAiB,CAAC,CAAC,EAAE,OAAO,CAAC,GAAG,CAAC,EAAE,CAAA;KACrC;CACF;AAED,KAAK,gBAAgB,GAAG,CAAC,IAAI,EAAE;IAC7B,OAAO,EAAE,yBAAyB,CAAA;IAClC,OAAO,EAAE,OAAO,CAAA;CACjB,KAAK,OAAO,CAAC,0BAA0B,CAAC,CAAA;AACzC,eAAO,MAAM,gBAAgB,EAAE,gBAuN9B,CAAA"}
@@ -14,10 +14,16 @@ export const processMultipart = async ({ options, request })=>{
14
14
  let filesCompleted = 0;
15
15
  let allFilesHaveResolved;
16
16
  let failedResolvingFiles;
17
+ let busboyFinishedResolve;
18
+ let busboyFinishedReject;
17
19
  const allFilesComplete = new Promise((res, rej)=>{
18
20
  allFilesHaveResolved = res;
19
21
  failedResolvingFiles = rej;
20
22
  });
23
+ const busboyFinished = new Promise((resolve, reject)=>{
24
+ busboyFinishedResolve = resolve;
25
+ busboyFinishedReject = reject;
26
+ });
21
27
  const result = {
22
28
  fields: undefined,
23
29
  files: undefined
@@ -136,16 +142,18 @@ export const processMultipart = async ({ options, request })=>{
136
142
  debugLog(options, `Error waiting for file write promises: ${err}`);
137
143
  }
138
144
  }
139
- return result;
145
+ busboyFinishedResolve();
140
146
  });
141
147
  busboy.on('error', (err = new APIError('Busboy error parsing multipart request', httpStatus.BAD_REQUEST))=>{
142
148
  debugLog(options, `Busboy error`);
143
- throw err;
149
+ const busboyError = err instanceof Error ? err : new APIError('Busboy error parsing multipart request', httpStatus.BAD_REQUEST);
150
+ busboyFinishedReject(busboyError);
144
151
  });
145
152
  while(parsingRequest){
146
153
  const { done, value } = await reader.read();
147
154
  if (done) {
148
155
  parsingRequest = false;
156
+ busboy.end();
149
157
  }
150
158
  if (value && !shouldAbortProccessing) {
151
159
  busboy.write(value);
@@ -156,6 +164,7 @@ export const processMultipart = async ({ options, request })=>{
156
164
  throw e;
157
165
  });
158
166
  }
167
+ await busboyFinished;
159
168
  return result;
160
169
  };
161
170
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/uploads/fetchAPI-multipart/processMultipart.ts"],"sourcesContent":["import type { Readable } from 'stream'\n\nimport Busboy from 'busboy'\nimport { status as httpStatus } from 'http-status'\n\nimport type { FetchAPIFileUploadOptions } from '../../config/types.js'\nimport type { FetchAPIFileUploadResponse } from './index.js'\n\nimport { APIError } from '../../errors/APIError.js'\nimport { fileFactory } from './fileFactory.js'\nimport { memHandler, tempFileHandler } from './handlers.js'\nimport { processNested } from './processNested.js'\nimport { createUploadTimer } from './uploadTimer.js'\nimport { buildFields, debugLog, isFunc, parseFileName } from './utilities.js'\n\nconst waitFlushProperty = Symbol('wait flush property symbol')\n\ndeclare global {\n interface Request {\n [waitFlushProperty]?: Promise<any>[]\n }\n}\n\ntype ProcessMultipart = (args: {\n options: FetchAPIFileUploadOptions\n request: Request\n}) => Promise<FetchAPIFileUploadResponse>\nexport const processMultipart: ProcessMultipart = async ({ options, request }) => {\n let parsingRequest = true\n\n let shouldAbortProccessing = false\n let fileCount = 0\n let filesCompleted = 0\n let allFilesHaveResolved: (value?: unknown) => void\n let failedResolvingFiles: (err: Error) => void\n\n const allFilesComplete = new Promise((res, rej) => {\n allFilesHaveResolved = res\n failedResolvingFiles = rej\n })\n\n const result: FetchAPIFileUploadResponse = {\n fields: undefined!,\n files: undefined!,\n }\n\n const headersObject: Record<string, string> = {}\n request.headers.forEach((value, name) => {\n headersObject[name] = value\n })\n\n const reader = request.body?.getReader()\n\n const busboy = Busboy({ ...options, headers: headersObject })\n\n function abortAndDestroyFile(file: Readable, err: APIError) {\n file.destroy()\n shouldAbortProccessing = true\n failedResolvingFiles(err)\n }\n\n // Build multipart req.body fields\n busboy.on('field', (field, val) => {\n result.fields = buildFields(result.fields, field, val)\n })\n\n // Build req.files fields\n busboy.on('file', (field, file, info) => {\n fileCount += 1\n // Parse file name(cutting huge names, decoding, etc..).\n const { encoding, filename: name, mimeType: mime } = info\n const filename = parseFileName(options, name)\n\n const inferredMimeType =\n (filename && filename.endsWith('.glb') && 'model/gltf-binary') ||\n (filename && filename.endsWith('.gltf') && 'model/gltf+json') ||\n mime\n\n // Define methods and handlers for upload process.\n const { cleanup, complete, dataHandler, getFilePath, getFileSize, getHash, getWritePromise } =\n options.useTempFiles\n ? tempFileHandler(options, field, filename) // Upload into temporary file.\n : memHandler(options, field, filename) // Upload into RAM.\n\n const writePromise = options.useTempFiles\n ? getWritePromise().catch(() => {\n busboy.end()\n cleanup()\n })\n : getWritePromise()\n\n const uploadTimer = createUploadTimer(options.uploadTimeout, () => {\n return abortAndDestroyFile(\n file,\n new APIError(`Upload timeout for ${field}->${filename}, bytes:${getFileSize()}`),\n )\n })\n\n file.on('limit', () => {\n debugLog(options, `Size limit reached for ${field}->${filename}, bytes:${getFileSize()}`)\n uploadTimer.clear()\n\n if (isFunc(options.limitHandler)) {\n options.limitHandler({ request, size: getFileSize() })\n }\n\n // Return error and cleanup files if abortOnLimit set.\n if (options.abortOnLimit) {\n debugLog(options, `Upload file size limit reached ${field}->${filename}.`)\n cleanup()\n abortAndDestroyFile(\n file,\n new APIError(options.responseOnLimit!, httpStatus.REQUEST_ENTITY_TOO_LARGE, {\n size: getFileSize(),\n }),\n )\n }\n })\n\n file.on('data', (data) => {\n uploadTimer.set()\n dataHandler(data)\n })\n\n file.on('end', () => {\n const size = getFileSize()\n debugLog(options, `Upload finished ${field}->${filename}, bytes:${size}`)\n uploadTimer.clear()\n\n if (!name && size === 0) {\n fileCount -= 1\n if (options.useTempFiles) {\n cleanup()\n debugLog(options, `Removing the empty file ${field}->${filename}`)\n }\n return debugLog(options, `Don't add file instance if original name and size are empty`)\n }\n\n filesCompleted += 1\n\n result.files = buildFields(\n result.files,\n field,\n fileFactory(\n {\n name: filename,\n buffer: complete(),\n encoding,\n hash: getHash(),\n mimetype: inferredMimeType,\n size,\n tempFilePath: getFilePath(),\n truncated: Boolean('truncated' in file && file.truncated) || false,\n },\n options,\n ),\n )\n\n if (!request[waitFlushProperty]) {\n request[waitFlushProperty] = []\n }\n request[waitFlushProperty].push(writePromise)\n\n if (filesCompleted === fileCount) {\n allFilesHaveResolved()\n }\n })\n\n file.on('error', (err) => {\n uploadTimer.clear()\n debugLog(options, `File Error: ${err.message}`)\n cleanup()\n failedResolvingFiles(err)\n })\n\n // Start upload process.\n debugLog(options, `New upload started ${field}->${filename}, bytes:${getFileSize()}`)\n uploadTimer.set()\n })\n\n busboy.on('finish', async () => {\n debugLog(options, `Busboy finished parsing request.`)\n if (options.parseNested) {\n result.fields = processNested(result.fields)\n result.files = processNested(result.files)\n }\n\n if (request[waitFlushProperty]) {\n try {\n await Promise.all(request[waitFlushProperty]).then(() => {\n delete request[waitFlushProperty]\n })\n } catch (err) {\n debugLog(options, `Error waiting for file write promises: ${err}`)\n }\n }\n\n return result\n })\n\n busboy.on(\n 'error',\n (err = new APIError('Busboy error parsing multipart request', httpStatus.BAD_REQUEST)) => {\n debugLog(options, `Busboy error`)\n throw err\n },\n )\n\n while (parsingRequest) {\n const { done, value } = await reader!.read()\n\n if (done) {\n parsingRequest = false\n }\n\n if (value && !shouldAbortProccessing) {\n busboy.write(value)\n }\n }\n\n if (fileCount !== 0) {\n await allFilesComplete.catch((e) => {\n throw e\n })\n }\n\n return result\n}\n"],"names":["Busboy","status","httpStatus","APIError","fileFactory","memHandler","tempFileHandler","processNested","createUploadTimer","buildFields","debugLog","isFunc","parseFileName","waitFlushProperty","Symbol","processMultipart","options","request","parsingRequest","shouldAbortProccessing","fileCount","filesCompleted","allFilesHaveResolved","failedResolvingFiles","allFilesComplete","Promise","res","rej","result","fields","undefined","files","headersObject","headers","forEach","value","name","reader","body","getReader","busboy","abortAndDestroyFile","file","err","destroy","on","field","val","info","encoding","filename","mimeType","mime","inferredMimeType","endsWith","cleanup","complete","dataHandler","getFilePath","getFileSize","getHash","getWritePromise","useTempFiles","writePromise","catch","end","uploadTimer","uploadTimeout","clear","limitHandler","size","abortOnLimit","responseOnLimit","REQUEST_ENTITY_TOO_LARGE","data","set","buffer","hash","mimetype","tempFilePath","truncated","Boolean","push","message","parseNested","all","then","BAD_REQUEST","done","read","write","e"],"mappings":"AAEA,OAAOA,YAAY,SAAQ;AAC3B,SAASC,UAAUC,UAAU,QAAQ,cAAa;AAKlD,SAASC,QAAQ,QAAQ,2BAA0B;AACnD,SAASC,WAAW,QAAQ,mBAAkB;AAC9C,SAASC,UAAU,EAAEC,eAAe,QAAQ,gBAAe;AAC3D,SAASC,aAAa,QAAQ,qBAAoB;AAClD,SAASC,iBAAiB,QAAQ,mBAAkB;AACpD,SAASC,WAAW,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,aAAa,QAAQ,iBAAgB;AAE7E,MAAMC,oBAAoBC,OAAO;AAYjC,OAAO,MAAMC,mBAAqC,OAAO,EAAEC,OAAO,EAAEC,OAAO,EAAE;IAC3E,IAAIC,iBAAiB;IAErB,IAAIC,yBAAyB;IAC7B,IAAIC,YAAY;IAChB,IAAIC,iBAAiB;IACrB,IAAIC;IACJ,IAAIC;IAEJ,MAAMC,mBAAmB,IAAIC,QAAQ,CAACC,KAAKC;QACzCL,uBAAuBI;QACvBH,uBAAuBI;IACzB;IAEA,MAAMC,SAAqC;QACzCC,QAAQC;QACRC,OAAOD;IACT;IAEA,MAAME,gBAAwC,CAAC;IAC/Cf,QAAQgB,OAAO,CAACC,OAAO,CAAC,CAACC,OAAOC;QAC9BJ,aAAa,CAACI,KAAK,G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ACnB;QAEA,IAAIiB,SAAS,CAAChB,wBAAwB;YACpCqB,OAAOkD,KAAK,CAACvD;QACf;IACF;IAEA,IAAIf,cAAc,GAAG;QACnB,MAAMI,iBAAiBwC,KAAK,CAAC,CAAC2B;YAC5B,MAAMA;QACR;IACF;IAEA,OAAO/D;AACT,EAAC"}
1
+ {"version":3,"sources":["../../../src/uploads/fetchAPI-multipart/processMultipart.ts"],"sourcesContent":["import type { Readable } from 'stream'\n\nimport Busboy from 'busboy'\nimport { status as httpStatus } from 'http-status'\n\nimport type { FetchAPIFileUploadOptions } from '../../config/types.js'\nimport type { FetchAPIFileUploadResponse } from './index.js'\n\nimport { APIError } from '../../errors/APIError.js'\nimport { fileFactory } from './fileFactory.js'\nimport { memHandler, tempFileHandler } from './handlers.js'\nimport { processNested } from './processNested.js'\nimport { createUploadTimer } from './uploadTimer.js'\nimport { buildFields, debugLog, isFunc, parseFileName } from './utilities.js'\n\nconst waitFlushProperty = Symbol('wait flush property symbol')\n\ndeclare global {\n interface Request {\n [waitFlushProperty]?: Promise<any>[]\n }\n}\n\ntype ProcessMultipart = (args: {\n options: FetchAPIFileUploadOptions\n request: Request\n}) => Promise<FetchAPIFileUploadResponse>\nexport const processMultipart: ProcessMultipart = async ({ options, request }) => {\n let parsingRequest = true\n\n let shouldAbortProccessing = false\n let fileCount = 0\n let filesCompleted = 0\n let allFilesHaveResolved: (value?: unknown) => void\n let failedResolvingFiles: (err: Error) => void\n let busboyFinishedResolve: () => void\n let busboyFinishedReject: (err: Error) => void\n\n const allFilesComplete = new Promise((res, rej) => {\n allFilesHaveResolved = res\n failedResolvingFiles = rej\n })\n\n const busboyFinished = new Promise<void>((resolve, reject) => {\n busboyFinishedResolve = resolve\n busboyFinishedReject = reject\n })\n\n const result: FetchAPIFileUploadResponse = {\n fields: undefined!,\n files: undefined!,\n }\n\n const headersObject: Record<string, string> = {}\n request.headers.forEach((value, name) => {\n headersObject[name] = value\n })\n\n const reader = request.body?.getReader()\n\n const busboy = Busboy({ ...options, headers: headersObject })\n\n function abortAndDestroyFile(file: Readable, err: APIError) {\n file.destroy()\n shouldAbortProccessing = true\n failedResolvingFiles(err)\n }\n\n // Build multipart req.body fields\n busboy.on('field', (field, val) => {\n result.fields = buildFields(result.fields, field, val)\n })\n\n // Build req.files fields\n busboy.on('file', (field, file, info) => {\n fileCount += 1\n // Parse file name(cutting huge names, decoding, etc..).\n const { encoding, filename: name, mimeType: mime } = info\n const filename = parseFileName(options, name)\n\n const inferredMimeType =\n (filename && filename.endsWith('.glb') && 'model/gltf-binary') ||\n (filename && filename.endsWith('.gltf') && 'model/gltf+json') ||\n mime\n\n // Define methods and handlers for upload process.\n const { cleanup, complete, dataHandler, getFilePath, getFileSize, getHash, getWritePromise } =\n options.useTempFiles\n ? tempFileHandler(options, field, filename) // Upload into temporary file.\n : memHandler(options, field, filename) // Upload into RAM.\n\n const writePromise = options.useTempFiles\n ? getWritePromise().catch(() => {\n busboy.end()\n cleanup()\n })\n : getWritePromise()\n\n const uploadTimer = createUploadTimer(options.uploadTimeout, () => {\n return abortAndDestroyFile(\n file,\n new APIError(`Upload timeout for ${field}->${filename}, bytes:${getFileSize()}`),\n )\n })\n\n file.on('limit', () => {\n debugLog(options, `Size limit reached for ${field}->${filename}, bytes:${getFileSize()}`)\n uploadTimer.clear()\n\n if (isFunc(options.limitHandler)) {\n options.limitHandler({ request, size: getFileSize() })\n }\n\n // Return error and cleanup files if abortOnLimit set.\n if (options.abortOnLimit) {\n debugLog(options, `Upload file size limit reached ${field}->${filename}.`)\n cleanup()\n abortAndDestroyFile(\n file,\n new APIError(options.responseOnLimit!, httpStatus.REQUEST_ENTITY_TOO_LARGE, {\n size: getFileSize(),\n }),\n )\n }\n })\n\n file.on('data', (data) => {\n uploadTimer.set()\n dataHandler(data)\n })\n\n file.on('end', () => {\n const size = getFileSize()\n debugLog(options, `Upload finished ${field}->${filename}, bytes:${size}`)\n uploadTimer.clear()\n\n if (!name && size === 0) {\n fileCount -= 1\n if (options.useTempFiles) {\n cleanup()\n debugLog(options, `Removing the empty file ${field}->${filename}`)\n }\n return debugLog(options, `Don't add file instance if original name and size are empty`)\n }\n\n filesCompleted += 1\n\n result.files = buildFields(\n result.files,\n field,\n fileFactory(\n {\n name: filename,\n buffer: complete(),\n encoding,\n hash: getHash(),\n mimetype: inferredMimeType,\n size,\n tempFilePath: getFilePath(),\n truncated: Boolean('truncated' in file && file.truncated) || false,\n },\n options,\n ),\n )\n\n if (!request[waitFlushProperty]) {\n request[waitFlushProperty] = []\n }\n request[waitFlushProperty].push(writePromise)\n\n if (filesCompleted === fileCount) {\n allFilesHaveResolved()\n }\n })\n\n file.on('error', (err) => {\n uploadTimer.clear()\n debugLog(options, `File Error: ${err.message}`)\n cleanup()\n failedResolvingFiles(err)\n })\n\n // Start upload process.\n debugLog(options, `New upload started ${field}->${filename}, bytes:${getFileSize()}`)\n uploadTimer.set()\n })\n\n busboy.on('finish', async () => {\n debugLog(options, `Busboy finished parsing request.`)\n if (options.parseNested) {\n result.fields = processNested(result.fields)\n result.files = processNested(result.files)\n }\n\n if (request[waitFlushProperty]) {\n try {\n await Promise.all(request[waitFlushProperty]).then(() => {\n delete request[waitFlushProperty]\n })\n } catch (err) {\n debugLog(options, `Error waiting for file write promises: ${err}`)\n }\n }\n\n busboyFinishedResolve()\n })\n\n busboy.on(\n 'error',\n (err = new APIError('Busboy error parsing multipart request', httpStatus.BAD_REQUEST)) => {\n debugLog(options, `Busboy error`)\n const busboyError =\n err instanceof Error\n ? err\n : new APIError('Busboy error parsing multipart request', httpStatus.BAD_REQUEST)\n\n busboyFinishedReject(busboyError)\n },\n )\n\n while (parsingRequest) {\n const { done, value } = await reader!.read()\n\n if (done) {\n parsingRequest = false\n busboy.end()\n }\n\n if (value && !shouldAbortProccessing) {\n busboy.write(value)\n }\n }\n\n if (fileCount !== 0) {\n await allFilesComplete.catch((e) => {\n throw e\n })\n }\n\n await busboyFinished\n\n return result\n}\n"],"names":["Busboy","status","httpStatus","APIError","fileFactory","memHandler","tempFileHandler","processNested","createUploadTimer","buildFields","debugLog","isFunc","parseFileName","waitFlushProperty","Symbol","processMultipart","options","request","parsingRequest","shouldAbortProccessing","fileCount","filesCompleted","allFilesHaveResolved","failedResolvingFiles","busboyFinishedResolve","busboyFinishedReject","allFilesComplete","Promise","res","rej","busboyFinished","resolve","reject","result","fields","undefined","files","headersObject","headers","forEach","value","name","reader","body","getReader","busboy","abortAndDestroyFile","file","err","destroy","on","field","val","info","encoding","filename","mimeType","mime","inferredMimeType","endsWith","cleanup","complete","dataHandler","getFilePath","getFileSize","getHash","getWritePromise","useTempFiles","writePromise","catch","end","uploadTimer","uploadTimeout","clear","limitHandler","size","abortOnLimit","responseOnLimit","REQUEST_ENTITY_TOO_LARGE","data","set","buffer","hash","mimetype","tempFilePath","truncated","Boolean","push","message","parseNested","all","then","BAD_REQUEST","busboyError","Error","done","read","write","e"],"mappings":"AAEA,OAAOA,YAAY,SAAQ;AAC3B,SAASC,UAAUC,UAAU,QAAQ,cAAa;AAKlD,SAASC,QAAQ,QAAQ,2BAA0B;AACnD,SAASC,WAAW,QAAQ,mBAAkB;AAC9C,SAASC,UAAU,EAAEC,eAAe,QAAQ,gBAAe;AAC3D,SAASC,aAAa,QAAQ,qBAAoB;AAClD,SAASC,iBAAiB,QAAQ,mBAAkB;AACpD,SAASC,WAAW,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,aAAa,QAAQ,iBAAgB;AAE7E,MAAMC,oBAAoBC,OAAO;AAYjC,OAAO,MAAMC,mBAAqC,OAAO,EAAEC,OAAO,EAAEC,OAAO,EAAE;IAC3E,IAAIC,iBAAiB;IAErB,IAAIC,yBAAyB;IAC7B,IAAIC,YAAY;IAChB,IAAIC,iBAAiB;IACrB,IAAIC;IACJ,IAAIC;IACJ,IAAIC;IACJ,IAAIC;IAEJ,MAAMC,mBAAmB,IAAIC,QAAQ,CAACC,KAAKC;QACzCP,uBAAuBM;QACvBL,uBAAuBM;IACzB;IAEA,MAAMC,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IAAI7C,SAAS,0CAA0CD,WAAW0F,WAAW,CAAC;QACnFlF,SAASM,SAAS,CAAC,YAAY,CAAC;QAChC,MAAM6E,cACJ7C,eAAe8C,QACX9C,MACA,IAAI7C,SAAS,0CAA0CD,WAAW0F,WAAW;QAEnFnE,qBAAqBoE;IACvB;IAGF,MAAO3E,eAAgB;QACrB,MAAM,EAAE6E,IAAI,EAAEvD,KAAK,EAAE,GAAG,MAAME,OAAQsD,IAAI;QAE1C,IAAID,MAAM;YACR7E,iBAAiB;YACjB2B,OAAOyB,GAAG;QACZ;QAEA,IAAI9B,SAAS,CAACrB,wBAAwB;YACpC0B,OAAOoD,KAAK,CAACzD;QACf;IACF;IAEA,IAAIpB,cAAc,GAAG;QACnB,MAAMM,iBAAiB2C,KAAK,CAAC,CAAC6B;YAC5B,MAAMA;QACR;IACF;IAEA,MAAMpE;IAEN,OAAOG;AACT,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"addDataAndFileToRequest.d.ts","sourceRoot":"","sources":["../../src/utilities/addDataAndFileToRequest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAKvD,KAAK,uBAAuB,GAAG,CAAC,GAAG,EAAE,cAAc,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;AAErE;;GAEG;AACH,eAAO,MAAM,uBAAuB,EAAE,uBAiGrC,CAAA"}
1
+ {"version":3,"file":"addDataAndFileToRequest.d.ts","sourceRoot":"","sources":["../../src/utilities/addDataAndFileToRequest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAKvD,KAAK,uBAAuB,GAAG,CAAC,GAAG,EAAE,cAAc,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;AAErE;;GAEG;AACH,eAAO,MAAM,uBAAuB,EAAE,uBAkGrC,CAAA"}
@@ -11,6 +11,7 @@ import { processMultipartFormdata } from '../uploads/fetchAPI-multipart/index.js
11
11
  ].includes(method.toUpperCase()) && body) {
12
12
  const [contentType] = (headers.get('Content-Type') || '').split(';', 1);
13
13
  const bodyByteSize = parseInt(req.headers.get('Content-Length') || '0', 10);
14
+ const hasBodyStream = req.body !== null;
14
15
  if (contentType === 'application/json') {
15
16
  try {
16
17
  const text = await req.text?.();
@@ -25,7 +26,7 @@ import { processMultipartFormdata } from '../uploads/fetchAPI-multipart/index.js
25
26
  req.payload.logger.error(error);
26
27
  throw error;
27
28
  }
28
- } else if (bodyByteSize && contentType?.includes('multipart/')) {
29
+ } else if ((bodyByteSize || hasBodyStream) && contentType?.includes('multipart/')) {
29
30
  const { error, fields, files } = await processMultipartFormdata({
30
31
  options: {
31
32
  ...payload.config.bodyParser || {},
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utilities/addDataAndFileToRequest.ts"],"sourcesContent":["import type { PayloadRequest } from '../types/index.js'\n\nimport { APIError } from '../errors/APIError.js'\nimport { processMultipartFormdata } from '../uploads/fetchAPI-multipart/index.js'\n\ntype AddDataAndFileToRequest = (req: PayloadRequest) => Promise<void>\n\n/**\n * Mutates the Request, appending 'data' and 'file' if found\n */\nexport const addDataAndFileToRequest: AddDataAndFileToRequest = async (req) => {\n const { body, headers, method, payload } = req\n\n if (method && ['PATCH', 'POST', 'PUT'].includes(method.toUpperCase()) && body) {\n const [contentType] = (headers.get('Content-Type') || '').split(';', 1)\n const bodyByteSize = parseInt(req.headers.get('Content-Length') || '0', 10)\n\n if (contentType === 'application/json') {\n try {\n const text = await req.text?.()\n const data = text ? JSON.parse(text) : {}\n req.data = data\n // @ts-expect-error attach json method to request\n req.json = () => Promise.resolve(data)\n } catch (error) {\n if (error instanceof SyntaxError) {\n throw new APIError('Invalid JSON', 400)\n }\n req.payload.logger.error(error)\n throw error\n }\n } else if (bodyByteSize && contentType?.includes('multipart/')) {\n const { error, fields, files } = await processMultipartFormdata({\n options: {\n ...(payload.config.bodyParser || {}),\n ...(payload.config.upload || {}),\n },\n request: req as Request,\n })\n\n if (error) {\n throw new APIError(error.message)\n }\n\n if (files?.file) {\n req.file = files.file\n }\n\n if (fields?._payload && typeof fields._payload === 'string') {\n req.data = JSON.parse(fields._payload)\n }\n\n if (!req.file && fields?.file && typeof fields?.file === 'string') {\n let clientUploadContext, collectionSlug, filename, mimeType, size\n try {\n ;({ clientUploadContext, collectionSlug, filename, mimeType, size } = JSON.parse(\n fields.file,\n ))\n } catch {\n throw new APIError('A file name is required.', 400)\n }\n const uploadConfig = req.payload.collections[collectionSlug]!.config.upload\n\n if (!uploadConfig.handlers) {\n throw new APIError('uploadConfig.handlers is not present for ' + collectionSlug)\n }\n\n let response: null | Response = null\n let error: unknown\n\n for (const handler of uploadConfig.handlers) {\n try {\n const result = await handler(req, {\n doc: null!,\n params: {\n clientUploadContext, // Pass additional specific to adapters context returned from UploadHandler, then staticHandler can use them.\n collection: collectionSlug,\n filename,\n },\n })\n if (result) {\n response = result\n }\n // If we couldn't get the file from that handler, save the error and try other.\n } catch (err) {\n error = err\n }\n }\n\n if (!response) {\n if (error) {\n payload.logger.error(error)\n }\n\n throw new APIError('Expected response from the upload handler.')\n }\n\n req.file = {\n name: filename,\n clientUploadContext,\n data: Buffer.from(await response.arrayBuffer()),\n mimetype: response.headers.get('Content-Type') || mimeType,\n size,\n }\n }\n }\n }\n}\n"],"names":["APIError","processMultipartFormdata","addDataAndFileToRequest","req","body","headers","method","payload","includes","toUpperCase","contentType","get","split","bodyByteSize","parseInt","text","data","JSON","parse","json","Promise","resolve","error","SyntaxError","logger","fields","files","options","config","bodyParser","upload","request","message","file","_payload","clientUploadContext","collectionSlug","filename","mimeType","size","uploadConfig","collections","handlers","response","handler","result","doc","params","collection","err","name","Buffer","from","arrayBuffer","mimetype"],"mappings":"AAEA,SAASA,QAAQ,QAAQ,wBAAuB;AAChD,SAASC,wBAAwB,QAAQ,yCAAwC;AAIjF;;CAEC,GACD,OAAO,MAAMC,0BAAmD,OAAOC;IACrE,MAAM,EAAEC,IAAI,EA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F;AACF,EAAC"}
1
+ {"version":3,"sources":["../../src/utilities/addDataAndFileToRequest.ts"],"sourcesContent":["import type { PayloadRequest } from '../types/index.js'\n\nimport { APIError } from '../errors/APIError.js'\nimport { processMultipartFormdata } from '../uploads/fetchAPI-multipart/index.js'\n\ntype AddDataAndFileToRequest = (req: PayloadRequest) => Promise<void>\n\n/**\n * Mutates the Request, appending 'data' and 'file' if found\n */\nexport const addDataAndFileToRequest: AddDataAndFileToRequest = async (req) => {\n const { body, headers, method, payload } = req\n\n if (method && ['PATCH', 'POST', 'PUT'].includes(method.toUpperCase()) && body) {\n const [contentType] = (headers.get('Content-Type') || '').split(';', 1)\n const bodyByteSize = parseInt(req.headers.get('Content-Length') || '0', 10)\n const hasBodyStream = req.body !== null\n\n if (contentType === 'application/json') {\n try {\n const text = await req.text?.()\n const data = text ? JSON.parse(text) : {}\n req.data = data\n // @ts-expect-error attach json method to request\n req.json = () => Promise.resolve(data)\n } catch (error) {\n if (error instanceof SyntaxError) {\n throw new APIError('Invalid JSON', 400)\n }\n req.payload.logger.error(error)\n throw error\n }\n } else if ((bodyByteSize || hasBodyStream) && contentType?.includes('multipart/')) {\n const { error, fields, files } = await processMultipartFormdata({\n options: {\n ...(payload.config.bodyParser || {}),\n ...(payload.config.upload || {}),\n },\n request: req as Request,\n })\n\n if (error) {\n throw new APIError(error.message)\n }\n\n if (files?.file) {\n req.file = files.file\n }\n\n if (fields?._payload && typeof fields._payload === 'string') {\n req.data = JSON.parse(fields._payload)\n }\n\n if (!req.file && fields?.file && typeof fields?.file === 'string') {\n let clientUploadContext, collectionSlug, filename, mimeType, size\n try {\n ;({ clientUploadContext, collectionSlug, filename, mimeType, size } = JSON.parse(\n fields.file,\n ))\n } catch {\n throw new APIError('A file name is required.', 400)\n }\n const uploadConfig = req.payload.collections[collectionSlug]!.config.upload\n\n if (!uploadConfig.handlers) {\n throw new APIError('uploadConfig.handlers is not present for ' + collectionSlug)\n }\n\n let response: null | Response = null\n let error: unknown\n\n for (const handler of uploadConfig.handlers) {\n try {\n const result = await handler(req, {\n doc: null!,\n params: {\n clientUploadContext, // Pass additional specific to adapters context returned from UploadHandler, then staticHandler can use them.\n collection: collectionSlug,\n filename,\n },\n })\n if (result) {\n response = result\n }\n // If we couldn't get the file from that handler, save the error and try other.\n } catch (err) {\n error = err\n }\n }\n\n if (!response) {\n if (error) {\n payload.logger.error(error)\n }\n\n throw new APIError('Expected response from the upload handler.')\n }\n\n req.file = {\n name: filename,\n clientUploadContext,\n data: Buffer.from(await response.arrayBuffer()),\n mimetype: response.headers.get('Content-Type') || mimeType,\n size,\n }\n }\n }\n }\n}\n"],"names":["APIError","processMultipartFormdata","addDataAndFileToRequest","req","body","headers","method","payload","includes","toUpperCase","contentType","get","split","bodyByteSize","parseInt","hasBodyStream","text","data","JSON","parse","json","Promise","resolve","error","SyntaxError","logger","fields","files","options","config","bodyParser","upload","request","message","file","_payload","clientUploadContext","collectionSlug","filename","mimeType","size","uploadConfig","collections","handlers","response","handler","result","doc","params","collection","err","name","Buffer","from","arrayBuffer","mimetype"],"mappings":"AAEA,SAASA,QAAQ,QAAQ,wBAAuB;AAChD,SAASC,wBAAwB,QAAQ,yCAAwC;AAIjF;;CAEC,GACD,OAAO,MAAMC,0BAAmD,OAAOC;IACrE,MAAM,EAAEC,IAAI,EAAEC,OAAO,EAAEC,MAAM,EAAEC,OAAO,EAAE,GAAGJ;IAE3C,IAAIG,UAAU;QAAC;QAAS;QAAQ;KAAM,CAACE,QAAQ,CAACF,OAAOG,WAAW,OAAOL,MAAM;QAC7E,MAAM,CAACM,YAAY,GAAG,AAACL,CAAAA,QAAQM,GAAG,CAAC,mBAAmB,EAAC,EAAGC,KAAK,CAAC,KAAK;QACrE,MAAMC,eAAeC,SAASX,IAAIE,OAAO,CAACM,GAAG,CAAC,qBAAqB,KAAK;QACxE,MAAMI,gBAAgBZ,IAAIC,IAAI,KAAK;QAEnC,IAAIM,gBAAgB,oBAAoB;YACtC,IAAI;gBACF,MAAMM,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gBACF,EAAE,OAAM;oBACN,MAAM,IAAIlC,SAAS,4BAA4B;gBACjD;gBACA,MAAMyC,eAAetC,IAAII,OAAO,CAACmC,WAAW,CAACL,eAAe,CAAER,MAAM,CAACE,MAAM;gBAE3E,IAAI,CAACU,aAAaE,QAAQ,EAAE;oBAC1B,MAAM,IAAI3C,SAAS,8CAA8CqC;gBACnE;gBAEA,IAAIO,WAA4B;gBAChC,IAAIrB;gBAEJ,KAAK,MAAMsB,WAAWJ,aAAaE,QAAQ,CAAE;oBAC3C,IAAI;wBACF,MAAMG,SAAS,MAAMD,QAAQ1C,KAAK;4BAChC4C,KAAK;4BACLC,QAAQ;gCACNZ;gCACAa,YAAYZ;gCACZC;4BACF;wBACF;wBACA,IAAIQ,QAAQ;4BACVF,WAAWE;wBACb;oBACA,+EAA+E;oBACjF,EAAE,OAAOI,KAAK;wBACZ3B,QAAQ2B;oBACV;gBACF;gBAEA,IAAI,CAACN,UAAU;oBACb,IAAIrB,OAAO;wBACThB,QAAQkB,MAAM,CAACF,KAAK,CAACA;oBACvB;oBAEA,MAAM,IAAIvB,SAAS;gBACrB;gBAEAG,IAAI+B,IAAI,GAAG;oBACTiB,MAAMb;oBACNF;oBACAnB,MAAMmC,OAAOC,IAAI,CAAC,MAAMT,SAASU,WAAW;oBAC5CC,UAAUX,SAASvC,OAAO,CAACM,GAAG,CAAC,mBAAmB4B;oBAClDC;gBACF;YACF;QACF;IACF;AACF,EAAC"}
@@ -0,0 +1,41 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { addDataAndFileToRequest } from './addDataAndFileToRequest.js';
3
+ const createReqWithMultipartBody = ()=>{
4
+ const formData = new FormData();
5
+ formData.append('file', new Blob([
6
+ 'hello world'
7
+ ], {
8
+ type: 'text/plain'
9
+ }), 'hello.txt');
10
+ const request = new Request('http://localhost/api/upload', {
11
+ body: formData,
12
+ method: 'POST'
13
+ });
14
+ return {
15
+ body: request.body,
16
+ headers: request.headers,
17
+ method: request.method,
18
+ payload: {
19
+ collections: {},
20
+ config: {
21
+ bodyParser: {},
22
+ upload: {}
23
+ },
24
+ logger: {
25
+ error: ()=>{}
26
+ }
27
+ }
28
+ };
29
+ };
30
+ describe('addDataAndFileToRequest', ()=>{
31
+ it('should parse multipart form-data even when content-length is absent', async ()=>{
32
+ const req = createReqWithMultipartBody();
33
+ expect(req.headers.get('content-length')).toBeNull();
34
+ await addDataAndFileToRequest(req);
35
+ expect(req.file).toBeDefined();
36
+ expect(req.file?.name).toBe('hello.txt');
37
+ expect(req.file?.mimetype).toBe('text/plain');
38
+ });
39
+ });
40
+
41
+ //# sourceMappingURL=addDataAndFileToRequest.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utilities/addDataAndFileToRequest.spec.ts"],"sourcesContent":["import type { PayloadRequest } from '../types/index.js'\n\nimport { describe, expect, it } from 'vitest'\n\nimport { addDataAndFileToRequest } from './addDataAndFileToRequest.js'\n\ntype MinimalReq = Pick<PayloadRequest, 'body' | 'headers' | 'method' | 'payload'> & {\n file?: PayloadRequest['file']\n}\n\nconst createReqWithMultipartBody = (): MinimalReq => {\n const formData = new FormData()\n formData.append('file', new Blob(['hello world'], { type: 'text/plain' }), 'hello.txt')\n\n const request = new Request('http://localhost/api/upload', {\n body: formData,\n method: 'POST',\n })\n\n return {\n body: request.body,\n headers: request.headers,\n method: request.method,\n payload: {\n collections: {},\n config: {\n bodyParser: {},\n upload: {},\n },\n logger: {\n error: () => {},\n },\n } as unknown as PayloadRequest['payload'],\n }\n}\n\ndescribe('addDataAndFileToRequest', () => {\n it('should parse multipart form-data even when content-length is absent', async () => {\n const req = createReqWithMultipartBody()\n\n expect(req.headers.get('content-length')).toBeNull()\n\n await addDataAndFileToRequest(req as PayloadRequest)\n\n expect(req.file).toBeDefined()\n expect(req.file?.name).toBe('hello.txt')\n expect(req.file?.mimetype).toBe('text/plain')\n })\n})\n"],"names":["describe","expect","it","addDataAndFileToRequest","createReqWithMultipartBody","formData","FormData","append","Blob","type","request","Request","body","method","headers","payload","collections","config","bodyParser","upload","logger","error","req","get","toBeNull","file","toBeDefined","name","toBe","mimetype"],"mappings":"AAEA,SAASA,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ,SAAQ;AAE7C,SAASC,uBAAuB,QAAQ,+BAA8B;AAMtE,MAAMC,6BAA6B;IACjC,MAAMC,WAAW,IAAIC;IACrBD,SAASE,MAAM,CAAC,QAAQ,IAAIC,KAAK;QAAC;KAAc,EAAE;QAAEC,MAAM;IAAa,IAAI;IAE3E,MAAMC,UAAU,IAAIC,QAAQ,+BAA+B;QACzDC,MAAMP;QACNQ,QAAQ;IACV;IAEA,OAAO;QACLD,MAAMF,QAAQE,IAAI;QAClBE,SAASJ,QAAQI,OAAO;QACxBD,QAAQH,QAAQG,MAAM;QACtBE,SAAS;YACPC,aAAa,CAAC;YACdC,QAAQ;gBACNC,YAAY,CAAC;gBACbC,QAAQ,CAAC;YACX;YACAC,QAAQ;gBACNC,OAAO,KAAO;YAChB;QACF;IACF;AACF;AAEArB,SAAS,2BAA2B;IAClCE,GAAG,uEAAuE;QACxE,MAAMoB,MAAMlB;QAEZH,OAAOqB,IAAIR,OAAO,CAACS,GAAG,CAAC,mBAAmBC,QAAQ;QAElD,MAAMrB,wBAAwBmB;QAE9BrB,OAAOqB,IAAIG,IAAI,EAAEC,WAAW;QAC5BzB,OAAOqB,IAAIG,IAAI,EAAEE,MAAMC,IAAI,CAAC;QAC5B3B,OAAOqB,IAAIG,IAAI,EAAEI,UAAUD,IAAI,CAAC;IAClC;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "payload",
3
- "version": "3.84.0-canary.0",
3
+ "version": "3.84.0-internal.d5d6e43",
4
4
  "description": "Node, React, Headless CMS and Application Framework built on Next.js",
5
5
  "keywords": [
6
6
  "admin panel",
@@ -115,7 +115,7 @@
115
115
  "undici": "7.24.4",
116
116
  "uuid": "11.1.0",
117
117
  "ws": "^8.16.0",
118
- "@payloadcms/translations": "3.84.0-canary.0"
118
+ "@payloadcms/translations": "3.84.0-internal.d5d6e43"
119
119
  },
120
120
  "devDependencies": {
121
121
  "@hyrious/esbuild-plugin-commonjs": "0.2.6",