{"version":3,"file":"upload.mjs","sources":["../../../server/src/middlewares/upload.ts"],"sourcesContent":["import range from 'koa-range';\nimport koaStatic from 'koa-static';\n\nimport type { Core } from '@strapi/types';\n\n/**\n * Programmatic upload middleware. We do not want to expose it in the plugin\n */\nexport default ({ strapi }: { strapi: Core.Strapi }) => {\n strapi.server.app.on('error', (err) => {\n if (err.code === 'EPIPE') {\n // when serving audio or video the browsers sometimes close the connection to go to range requests instead.\n // This causes koa to emit a write EPIPE error. We can ignore it.\n // Right now this ignores it globally and we cannot do much more because it is how koa handles it.\n return;\n }\n\n strapi.server.app.onerror(err);\n });\n\n const localServerConfig = strapi.config.get('plugin::upload.providerOptions.localServer', {});\n\n strapi.server.routes([\n {\n method: 'GET',\n path: '/uploads/(.*)',\n handler: [range, koaStatic(strapi.dirs.static.public, { defer: true, ...localServerConfig })],\n config: { auth: false },\n },\n ]);\n};\n"],"names":["strapi","server","app","on","err","code","onerror","localServerConfig","config","get","routes","method","path","handler","range","koaStatic","dirs","static","public","defer","auth"],"mappings":";;;AAKA;;AAEC,IACD,+BAAe,CAAA,CAAC,EAAEA,MAAM,EAA2B,GAAA;AACjDA,IAAAA,MAAAA,CAAOC,MAAM,CAACC,GAAG,CAACC,EAAE,CAAC,SAAS,CAACC,GAAAA,GAAAA;QAC7B,IAAIA,GAAAA,CAAIC,IAAI,KAAK,OAAS,EAAA;;;;AAIxB,YAAA;AACF;AAEAL,QAAAA,MAAAA,CAAOC,MAAM,CAACC,GAAG,CAACI,OAAO,CAACF,GAAAA,CAAAA;AAC5B,KAAA,CAAA;AAEA,IAAA,MAAMG,oBAAoBP,MAAOQ,CAAAA,MAAM,CAACC,GAAG,CAAC,8CAA8C,EAAC,CAAA;IAE3FT,MAAOC,CAAAA,MAAM,CAACS,MAAM,CAAC;AACnB,QAAA;YACEC,MAAQ,EAAA,KAAA;YACRC,IAAM,EAAA,eAAA;YACNC,OAAS,EAAA;AAACC,gBAAAA,KAAAA;AAAOC,gBAAAA,SAAAA,CAAUf,OAAOgB,IAAI,CAACC,MAAM,CAACC,MAAM,EAAE;oBAAEC,KAAO,EAAA,IAAA;AAAM,oBAAA,GAAGZ;AAAkB,iBAAA;AAAG,aAAA;YAC7FC,MAAQ,EAAA;gBAAEY,IAAM,EAAA;AAAM;AACxB;AACD,KAAA,CAAA;AACH,CAAA;;;;"}