{"record":{"id":"7cc9b11e6d485f52","repo":"vercel/ai","slug":"deepseek-file-uploads-support-jpeg-png-gif-and","errorCode":null,"errorMessage":"DeepSeek file uploads support JPEG, PNG, GIF, and WebP images. Detected unsupported file content type \"${detectedMediaType}\".","messagePattern":"DeepSeek file uploads support JPEG, PNG, GIF, and WebP images\\. Detected unsupported file content type \"(.+?)\"\\.","errorType":"validation","errorClass":"InvalidArgumentError","httpStatus":null,"severity":"error","filePath":"packages/deepseek/src/files/deepseek-files.ts","lineNumber":183,"sourceCode":"\n    if (filenameLength > MAX_FILENAME_LENGTH) {\n      throw new InvalidArgumentError({\n        argument: 'filename',\n        message:\n          `DeepSeek filenames must not exceed ${MAX_FILENAME_LENGTH} characters. ` +\n          `Received ${filenameLength} characters.`,\n      });\n    }\n  }\n\n  const normalizedMediaType = normalizeMediaType(mediaType);\n  const detectedMediaType = detectMediaType({ data: fileBytes });\n\n  if (\n    detectedMediaType != null &&\n    !supportedMediaTypes.has(detectedMediaType)\n  ) {\n    throw new InvalidArgumentError({\n      argument: 'data',\n      message:\n        `DeepSeek file uploads support JPEG, PNG, GIF, and WebP images. ` +\n        `Detected unsupported file content type \"${detectedMediaType}\".`,\n    });\n  }\n\n  if (supportedMediaTypes.has(normalizedMediaType)) {\n    return;\n  }\n\n  if (!genericMediaTypes.has(normalizedMediaType)) {\n    throw new InvalidArgumentError({\n      argument: 'mediaType',\n      message:\n        `DeepSeek file uploads support JPEG, PNG, GIF, and WebP images. ` +\n        `Received unsupported media type \"${mediaType}\".`,\n    });","sourceCodeStart":165,"sourceCodeEnd":201,"githubUrl":"https://github.com/vercel/ai/blob/69428b1f8b037e4d118fb4853428d5c4e620493c/packages/deepseek/src/files/deepseek-files.ts#L165-L201","documentation":"The provider sniffs the actual bytes of the upload (detectMediaType) and rejects files whose detected content is not one of the supported image types (JPEG, PNG, GIF, WebP), throwing InvalidArgumentError for argument 'data'. This catches cases where the declared mediaType does not match the real content, e.g. a PDF or text file labeled as an image.","triggerScenarios":"Uploading to deepseek.files.upload a file whose magic-byte signature detects as an unsupported type (PDF, MP4, SVG, text, etc.), regardless of the mediaType argument.","commonSituations":"Passing documents (PDFs) or videos to a files API that only accepts images, or mislabeled uploads where the extension/mediaType says PNG but the payload is something else.","solutions":["Only upload JPEG, PNG, GIF, or WebP image data to DeepSeek files.","Convert unsupported content (e.g. PDF pages, HEIC, TIFF) to PNG/JPEG before uploading.","Detect the content type yourself first (or fix the source of mislabeled data) so you can fail with a friendlier message."],"exampleFix":"// before\nawait files.upload({ data: pdfBytes, mediaType: 'application/pdf' });\n\n// after\n// convert first page to an image, e.g. with pdf-to-image / sharp\nconst png = await renderPdfPageToPng(pdfBytes, 0);\nawait files.upload({ data: png, mediaType: 'image/png', filename: 'page-1.png' });","handlingStrategy":"validation","validationCode":"const SUPPORTED = new Set(['image/jpeg', 'image/png', 'image/gif', 'image/webp']);\nconst detected = detectMediaType({ data: fileBytes });\nif (detected && !SUPPORTED.has(detected)) {\n  throw new Error(`Unsupported upload content: ${detected}. Convert to JPEG/PNG/GIF/WebP first.`);\n}","typeGuard":null,"tryCatchPattern":"import { InvalidArgumentError } from '@ai-sdk/provider';\ntry {\n  await files.upload({ data: fileBytes, mediaType });\n} catch (e) {\n  if (InvalidArgumentError.isInstance(e) && e.argument === 'data') {\n    // convert content to a supported image type before retrying\n  } else throw e;\n}","preventionTips":["Whitelist image inputs at the application boundary before they reach the upload code.","Never trust declared mediaType for documents/videos; sniff or enforce extensions.","Provide a conversion path (PDF->PNG, HEIC->JPEG) for common non-image inputs."],"tags":["file-upload","media-type","content-sniffing","validation"],"backgroundTag":"unsupported-media-type","analyzedSha":"69428b1f8b037e4d118fb4853428d5c4e620493c","analyzedAt":"2026-08-30T12:32:21.016Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}