You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: auto-detect MIME type for file uploads (fixes image upload error)
- Add MimeTypes helper mapping 18 extensions to Content-Type
- UploadFileDataAsync/ResumableAsync now use detected MIME from fileName
- Fixes 'Error reading file from request in direct mode' on iu.oneme.ru CDN
- Document format restrictions: HTML/unsupported extensions return 'File extension is forbidden'
- Add unit tests for MIME detection (image, unknown, null)
- Bump version 0.6.2-alpha -> 0.6.3-alpha
- Update CHANGELOG
Copy file name to clipboardExpand all lines: CHANGELOG.md
+14Lines changed: 14 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,6 +6,20 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
8
8
## [Unreleased]
9
+
## [0.6.3-alpha] - 2026-06-08
10
+
11
+
### Fixed
12
+
13
+
-**Image/Video/Audio upload MIME type**: `UploadFileDataAsync` and `UploadFileResumableAsync` no longer hardcode `Content-Type: application/octet-stream`. The MIME type is now auto-detected from the file name extension (e.g. `image/jpeg` for `.jpg`) and falls back to `application/octet-stream` for unknown extensions. This fixes the `"Error reading file from request in direct mode"` error that occurred when uploading images to the `iu.oneme.ru` CDN, which requires a correct MIME type for validation.
14
+
15
+
### Added
16
+
17
+
-**MIME type helper**: `Max.Bot.Networking.MimeTypes` maps 18 common file extensions to `Content-Type` values for images, video, and audio.
18
+
19
+
### Changed
20
+
21
+
-**Format restrictions documented**: `IFilesApi.UploadFileAsync` XML docs now note that unsupported extensions (e.g. `.html`) return `"File extension is forbidden"` from the Max API, and list supported formats per upload type.
/// <item><description>For <c>type=audio</c>, supported formats: MP3, WAV, M4A and others.</description></item>
24
+
/// </list>
25
+
/// </remarks>
17
26
/// <param name="uploadType">The type of file to upload.</param>
18
27
/// <param name="cancellationToken">A cancellation token to cancel the operation.</param>
19
28
/// <returns>A task that represents the asynchronous operation. The task result contains the upload response with URL and optional token.</returns>
@@ -27,8 +36,8 @@ public interface IFilesApi
27
36
/// </summary>
28
37
/// <param name="uploadUrl">The upload URL obtained from UploadFileAsync.</param>
29
38
/// <param name="fileStream">The stream containing the file data to upload.</param>
30
-
/// <param name="fileName">The name of the file. Optional.</param>
31
39
/// <param name="cancellationToken">A cancellation token to cancel the operation.</param>
40
+
/// <param name="fileName">The name of the file. Used to determine the MIME type. If the extension is unknown, falls back to "application/octet-stream". Optional.</param>
32
41
/// <returns>A task that represents the asynchronous operation. The task result contains the upload result with a token.</returns>
33
42
/// <exception cref="ArgumentException">Thrown when uploadUrl is null or empty, or fileStream is not readable.</exception>
34
43
/// <exception cref="ArgumentNullException">Thrown when fileStream is null.</exception>
@@ -51,4 +60,3 @@ public interface IFilesApi
51
60
/// <exception cref="Max.Bot.Exceptions.MaxNetworkException">Thrown when a network error occurs.</exception>
0 commit comments