MCPcopy
hub / github.com/serverless/serverless / getFilename

Function getFilename

packages/sf-core/src/utils/https/index.js:418–437  ·  view source on GitHub ↗
(res, data)

Source from the content-addressed store, hash-verified

416 * @returns
417 */
418const getFilename = async (res, data) => {
419 const contentDisposition = res.headers.get('content-disposition')
420
421 if (contentDisposition) {
422 const matches = contentDisposition.match(/filename="(.+)"/)
423 if (matches?.[1]) {
424 return matches[1]
425 }
426 }
427
428 let filename = filenameFromPath(res)
429 if (!path.extname(filename)) {
430 const ext = getExtFromMime(res)
431 if (ext) {
432 filename = `${filename}.${ext}`
433 }
434 }
435
436 return filename
437}
438
439/**
440 * Main function to download and optionally save the file

Callers 1

downloadDataFromUriFunction · 0.85

Calls 3

filenameFromPathFunction · 0.85
getExtFromMimeFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…