{"record":{"id":"975bc2b1999f4753","repo":"vercel/ai","slug":"deepseek-file-uploads-support-jpeg-png-gif-and-975bc2","errorCode":null,"errorMessage":"DeepSeek file uploads support JPEG, PNG, GIF, and WebP images. Provide a supported media type or a filename ending in .jpg, .jpeg, .png, .gif, or .webp. Received \"${mediaType}\".","messagePattern":"DeepSeek file uploads support JPEG, PNG, GIF, and WebP images\\. Provide a supported media type or a filename ending in \\.jpg, \\.jpeg, \\.png, \\.gif, or \\.webp\\. Received \"(.+?)\"\\.","errorType":"validation","errorClass":"InvalidArgumentError","httpStatus":null,"severity":"error","filePath":"packages/deepseek/src/files/deepseek-files.ts","lineNumber":208,"sourceCode":"\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  });\n}\n\nfunction normalizeMediaType(mediaType: string): string {\n  return mediaType.split(';', 1)[0].trim().toLowerCase();\n}\n\nfunction hasSupportedFilenameExtension(filename: string | undefined): boolean {\n  if (filename == null) {\n    return false;\n  }\n\n  const extensionSeparatorIndex = filename.lastIndexOf('.');","sourceCodeStart":190,"sourceCodeEnd":226,"githubUrl":"https://github.com/vercel/ai/blob/69428b1f8b037e4d118fb4853428d5c4e620493c/packages/deepseek/src/files/deepseek-files.ts#L190-L226","documentation":"If the mediaType is generic (e.g. 'application/octet-stream'), the provider tries to resolve the real type by sniffing the bytes or by the filename extension. When neither yields a supported image type, it throws InvalidArgumentError for argument 'mediaType', asking for a supported media type or a .jpg/.jpeg/.png/.gif/.webp filename.","triggerScenarios":"Uploading generic-typed data where content sniffing fails (empty or ambiguous bytes) and the filename is missing or lacks a supported image extension, e.g. filename: 'blob' with mediaType: 'application/octet-stream'.","commonSituations":"Streaming in-memory blobs with no original filename, uploads from clients that strip filenames, or base64 payloads decoded without extension info.","solutions":["Pass an explicit supported mediaType ('image/png', 'image/jpeg', 'image/gif', 'image/webp').","Provide a filename ending in .jpg, .jpeg, .png, .gif, or .webp so the extension can disambiguate.","Ensure the byte payload is a real image so content sniffing succeeds (empty/truncated buffers cannot be detected)."],"exampleFix":"// before\nawait files.upload({ data, mediaType: 'application/octet-stream', filename: 'blob' });\n\n// after\nawait files.upload({ data, mediaType: 'application/octet-stream', filename: 'blob.png' });\n// or better: await files.upload({ data, mediaType: 'image/png' });","handlingStrategy":"validation","validationCode":"const SUPPORTED = /\\.(jpe?g|png|gif|webp)$/i;\nif (!SUPPORTED.test(filename ?? '') && !/^image\\/(jpeg|png|gif|webp)$/.test(mediaType)) {\n  throw new Error('Provide a supported image mediaType or a .jpg/.jpeg/.png/.gif/.webp filename');\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    // retry with explicit mediaType: 'image/png' (or correct type)\n  } else throw e;\n}","preventionTips":["Always pass an explicit supported mediaType when the source type is unknown.","Preserve the original filename (with extension) through your upload pipeline.","Validate that buffers are non-empty real images before uploading generic-typed data."],"tags":["file-upload","media-type","filename","validation"],"backgroundTag":"unsupported-media-type","analyzedSha":"69428b1f8b037e4d118fb4853428d5c4e620493c","analyzedAt":"2026-08-30T12:32:21.016Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}