{"record":{"id":"b204bd80a1252d54","repo":"vercel/ai","slug":"deepseek-file-uploads-support-jpeg-png-gif-and-b204bd","errorCode":null,"errorMessage":"DeepSeek file uploads support JPEG, PNG, GIF, and WebP images. Received unsupported media type \"${mediaType}\".","messagePattern":"DeepSeek file uploads support JPEG, PNG, GIF, and WebP images\\. Received unsupported media type \"(.+?)\"\\.","errorType":"validation","errorClass":"InvalidArgumentError","httpStatus":null,"severity":"error","filePath":"packages/deepseek/src/files/deepseek-files.ts","lineNumber":196,"sourceCode":"\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    });\n  }\n\n  if (detectedMediaType != null || hasSupportedFilenameExtension(filename)) {\n    return;\n  }\n\n  throw new InvalidArgumentError({\n    argument: 'mediaType',\n    message:\n      `DeepSeek file uploads support JPEG, PNG, GIF, and WebP images. ` +\n      `Provide a supported media type or a filename ending in ` +\n      `.jpg, .jpeg, .png, .gif, or .webp. Received \"${mediaType}\".`,\n  });","sourceCodeStart":178,"sourceCodeEnd":214,"githubUrl":"https://github.com/vercel/ai/blob/69428b1f8b037e4d118fb4853428d5c4e620493c/packages/deepseek/src/files/deepseek-files.ts#L178-L214","documentation":"When the caller-supplied mediaType is not a supported image type and also not a recognized generic type (e.g. 'application/octet-stream'), the provider throws InvalidArgumentError for argument 'mediaType'. Supported uploads are JPEG, PNG, GIF, and WebP; generic types fall through to content sniffing, but anything else is rejected outright.","triggerScenarios":"Calling deepseek.files.upload with mediaType values like 'image/heic', 'video/mp4', 'text/plain', or a typo such as 'image/jpg'.","commonSituations":"Passing MIME types from an allowlist meant for another provider (HEIC from iOS uploads), typos in MIME strings ('image/jpg' is not a real type), or forwarding provider-specific types.","solutions":["Pass one of image/jpeg, image/png, image/gif, or image/webp as mediaType.","Replace 'image/jpg' with 'image/jpeg' (a common typo that lands here).","If the true type is unknown, pass a generic type like 'application/octet-stream' and provide a supported filename extension so sniffing can resolve it."],"exampleFix":"// before\nawait files.upload({ data, mediaType: 'image/jpg' });\n\n// after\nawait files.upload({ data, mediaType: 'image/jpeg', filename: 'photo.jpg' });","handlingStrategy":"validation","validationCode":"const SUPPORTED = new Set(['image/jpeg', 'image/png', 'image/gif', 'image/webp']);\nconst GENERIC = new Set(['application/octet-stream', 'application/binary']);\nif (!SUPPORTED.has(mediaType) && !GENERIC.has(mediaType)) {\n  throw new Error(`mediaType ${mediaType} not accepted by DeepSeek uploads; use image/jpeg|png|gif|webp`);\n}","typeGuard":null,"tryCatchPattern":"import { InvalidArgumentError } from '@ai-sdk/provider';\ntry {\n  await files.upload({ data, mediaType, filename });\n} catch (e) {\n  if (InvalidArgumentError.isInstance(e) && e.argument === 'mediaType') {\n    await files.upload({ data, mediaType: normalizeMediaType(mediaType), filename });\n  } else throw e;\n}","preventionTips":["Normalize MIME types before upload ('image/jpg' -> 'image/jpeg').","Restrict upload inputs to the four supported image MIME types.","Share one media-type whitelist constant across your upload paths."],"tags":["file-upload","media-type","validation"],"backgroundTag":"unsupported-media-type","analyzedSha":"69428b1f8b037e4d118fb4853428d5c4e620493c","analyzedAt":"2026-08-30T12:32:21.016Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}